此内容已被标记为最终。 显示 3 条回复
I would suggest you look for a library meant for JPEG file handling. And maybe check out ImageIO to see whether you can do it with the standard Java API.
I tried many ways using ImageIO, ImageReader
ImageInputStream inStream = ImageIO.createImageInputStream(new File("E:\\Ramesh\\Blue hills.jpg"));
Iterator<ImageReader> imgItr = ImageIO.getImageReaders(inStream);
ImageReader reader = imgItr.next();
String fm = reader.getFormatName();
System.out.println("format name : " + fm );
Raster raster = reader.readRaster(0, null);
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 ] );
In that case, as already pointed out, libraries for extracting JPG metadata do exist and you should be able to find them. I have used one myself and it worked perfectly well. However this was four years ago, on a different computer, and I don't remember its name. That shouldn't stop you from finding it in under a minute yourself, though.