import java.io.File;
import java.util.Iterator;
import javax.imageio.ImageIO;
publicclass Main {
publicstaticvoid main(String[] argv) throws Exception {
boolean b;
// Check availability using a format name
b = canReadFormat("foo"); // false
b = canReadFormat("gif"); // true
b = canReadFormat("giF"); // true
}
// Returns true if the specified format name can be read
publicstaticboolean canReadFormat(String formatName) {
Iterator iter = ImageIO.getImageReadersByFormatName(formatName);
return iter.hasNext();
}
}