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;
// 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
public static boolean canWriteExtension(String fileExt) {
Iterator iter = ImageIO.getImageWritersBySuffix(fileExt);
return iter.hasNext();
}
}
|