我想使用Java代码从本地系统中的映像文件中获取元数据
在附图中,您可以看到我想从java代码中提取的所需数据.
我编写了下面的代码,似乎没有拉出"详细信息"选项卡中提到的数据.下面代码的输出是,这不是我想要的.
Started ..
Format name: javax_imageio_jpeg_image_1.0
Format name: javax_imageio_1.0
Run Code Online (Sandbox Code Playgroud)
请把你的想法告诉我.谢谢
try {
ImageInputStream inStream = ImageIO.createImageInputStream(new File("D:\\codeTest\\arun.jpg"));
Iterator<ImageReader> imgItr = ImageIO.getImageReaders(inStream);
while (imgItr.hasNext()) {
ImageReader reader = imgItr.next();
reader.setInput(inStream, true);
IIOMetadata metadata = reader.getImageMetadata(0);
String[] names = metadata.getMetadataFormatNames();
int length = names.length;
for (int i = 0; i < length; i++) {
System.out.println( "Format name: " + names[ i ] );
}
}
} catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud) 我需要将某些bash
脚本转换为,java
并且使用openssl
a vanity-url
作为参数将一个这样的脚本连接到服务器,以检查使用该参数是否可连接vanity-url
。参见下面的命令
/usr/bin/openssl s_client -connect api.sys.found1.cf.company.com:443 -servername www.app.company.com 2>/dev/null
我想在其中进行类似的活动java
并测试连通性。关于如何open-ssl
使用Java 建立连接的任何想法。这是我需要使用外部库吗?
我想测试Spring Cloud Vault配置.
我在本地安装了一个Vault服务器,当我尝试write
一些键值时它失败并要求我使用vault kv put
命令.
虽然此链接中的Spring Cloud Config示例显示了Vault写入命令的用法
这是我得到的错误
$ vault write secret/my-app foo=bar
Error writing data to secret/my-app: Error making API request.
URL: PUT http://127.0.0.1:8200/v1/secret/my-app
Code: 404. Errors:
WARNING! The following warnings were returned from Vault:
* Invalid path for a versioned K/V secrets engine. See the API docs for the
appropriate API endpoints to use. If using the Vault CLI, use 'vault kv put'
for this operation.
Run Code Online (Sandbox Code Playgroud) spring spring-cloud hashicorp-vault spring-cloud-vault-config
我使用查询字符串将数据从JSP发送到控制器.
我的控制器是注释驱动的.
请求参数的值应不区分大小写.
我用于欢迎页面的方法是
public String welcome(@RequestParam("orgID") String orgID, ModelMap model)
Run Code Online (Sandbox Code Playgroud)
请求参数"orgID"应不区分大小写.这该怎么做 ?.
我应该能够将查询字符串作为"orgid"或"orgId".该参数应完全不区分大小写.寻找你的帮助朋友.
提前致谢 :-)
我有两个任务Task-A
和Task-B
这是我的任务-A
task Task-A () {
doLast {
def fileName = _.property('fileName')
if (fileName !=null) {
println 'success'
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的Task-B依赖于 Task-A,我应该让它只依赖于_.property('fileName')
应该存在且不应该为空的条件
所以我这样写了我的任务-B
task Task-B () {
doFirst {
def fileName = _.property('fileName')
if (fileName !=null) {
dependsOn 'Task-A'
}
}
}
Run Code Online (Sandbox Code Playgroud)
它抛出一个错误
Cannot call Task.dependsOn(Object...) on task ':Task-B' after task has started execution.
如何dependsOn
在条件下执行?
假设我System.out.println(message)
在所有地方打字都很无聊,我在java中介绍一个看起来像的方法
private void print (Object message) {
System.out.println(message);
}
Run Code Online (Sandbox Code Playgroud)
我会在必要的地方调用print (2)
&print ("hi")
.
也可以在GoLang实现同样的目标吗?这样的功能
func print(message ) {
fmt.Println (message)
}
Run Code Online (Sandbox Code Playgroud) 我有一个现有的Spring boot
应用程序,我建立gradle
.这些天我一直在使用JDK / JRE 8
,现在我正在尝试使用JDK-11
因此,要检查兼容性,我设置JAVA_HOME
到JDK-11
,但试图编译Java 8
模式
我在下面添加了以下块 build.gradle
compileJava {
targetCompatibility = '1.8'
}
Run Code Online (Sandbox Code Playgroud)
然后我JAVA_HOME
明确地设置set JAVA_HOME=C:\Users\arun\Desktop\jdk-11.0.1
然后执行 gradlew clean build
但是我因以下例外而停止了
> Configure project :
Build Version = build-182-ga03cf6c
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> warning: source release 11 requires target release 11
Run Code Online (Sandbox Code Playgroud)
如何指向我JAVA_HOME
来JDK-11
,但仍然在执行它Java-8 …
当我执行以下代码
File f = new File("c:/sample.pdf");
PdfWriter.getInstance(document, new FileOutputStream(f));
document.open();
System.out.println("opening the document..");
PdfPTable headerTable=new PdfPTable(9);
PdfPCell cellValue = new PdfPCell(new Paragraph("Header 1"));
cellValue.setColspan(1);
headerTable.addCell(cellValue);
cellValue = new PdfPCell(new Paragraph("Header 2"));
headerTable.addCell(cellValue);
cellValue = new PdfPCell(new Paragraph("Header 3"));
headerTable.addCell(cellValue);
cellValue = new PdfPCell(new Paragraph("Header 4"));
headerTable.addCell(cellValue);
PdfPTable subHeaderTable = new PdfPTable(3);
PdfPCell subHeadingCell = new PdfPCell(new Paragraph("Header 5"));
subHeadingCell.setColspan(3);
subHeaderTable.addCell(subHeadingCell);
subHeaderTable.addCell("Sub heading 1");
subHeaderTable.addCell("Sub heading 2");
subHeaderTable.addCell("Sub heading 3");
headerTable.addCell(subHeaderTable);
document.add(headerTable);
document.close();
Run Code Online (Sandbox Code Playgroud)
我得到以下异常.请帮忙
ExceptionConverter: java.io.IOException: The document has no pages. …
Run Code Online (Sandbox Code Playgroud) 我想在我的第一个SpringBoot应用程序中启动我的登录页面:
主类
@SpringBootApplication
public class MainGate extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(MainGate.class);
}
public static void main(String... args) {
System.out.println("Booting .. ");
SpringApplication.run(MainGate.class, args) ;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的Gradle文件
buildscript {
ext {
springBootVersion = '1.5.4.RELEASE'
}
repositories {
maven {
url "http://masked_domain/repository/external-proxy-group/"
}
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'com.arun'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
task fatJar(type: Jar) …
Run Code Online (Sandbox Code Playgroud) 我从google的webserivce获取经度和纬度值,并将值传递给打开的天气图api以获取温度值.代码如下
function getWeatherData(latitude, longitude) {
var temperature = 0;
var url = "http://api.openweathermap.org/data/2.5/weather?lat=";
url = url + latitude;
url = url + "&lon=";
url = url + longitude;
url = url + "&cnt=1";
$
.ajax({
type : "POST",
dataType : "jsonp",
url : url + "&callback=?",
async : false,
success : function(data) {
temperature = data.list[0].main.temp ;
alert (temperature);
},
error : function(errorData) {
alert("Error while getting weather data :: "+errorData.status);
}
});
return temperature;
Run Code Online (Sandbox Code Playgroud)
所以对于这个URL
http://api.openweathermap.org/data/2.1/find/city?lat=22.572646&lon=88.36389500000001&cnt=1
Run Code Online (Sandbox Code Playgroud)
我在浏览器中正确获得了以下JSON响应
{
"message": …
Run Code Online (Sandbox Code Playgroud) java ×5
spring ×3
gradle ×2
java-8 ×2
annotations ×1
build.gradle ×1
go ×1
heatmap ×1
image ×1
itext ×1
java-11 ×1
javascript ×1
jpeg ×1
jquery ×1
jsp ×1
metadata ×1
openssl ×1
spring-boot ×1
spring-cloud ×1
spring-mvc ×1
weather-api ×1