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 = canReadExtension("foo"); // false
b = canReadExtension("gif"); // true
b = canReadExtension("giF"); // true
}
// Returns true if the specified file extension can be read
publicstaticboolean canReadExtension(String fileExt) {
Iterator iter = ImageIO.getImageReadersBySuffix(fileExt);
return iter.hasNext();
}
}