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