import java.util.Iterator;
import javax.imageio.ImageIO;
public class Main {
public static void main(String[] argv) throws Exception {
boolean b;
b = canReadMimeType("image/jpg"); // false
b = canReadMimeType("image/jpeg"); // true
}
// Returns true if the specified mime type can be read
public static boolean canReadMimeType(String mimeType) {
Iterator iter = ImageIO.getImageReadersByMIMEType(mimeType);
return iter.hasNext();
}
}
|