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