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 = canWriteFormat("foo"); // false
b = canWriteFormat("gif"); // true
b = canWriteFormat("giF"); // true
}
public static boolean canWriteFormat(String formatName) {
Iterator iter = ImageIO.getImageWritersByFormatName(formatName);
return iter.hasNext();
}
}
|