Mega Code Archive

 
Categories / Java Tutorial / 2D Graphics
 

Returns true if the specified format name can be read

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 = canReadFormat("foo"); // false     b = canReadFormat("gif"); // true     b = canReadFormat("giF"); // true     }   // Returns true if the specified format name can be read   public static boolean canReadFormat(String formatName) {     Iterator iter = ImageIO.getImageReadersByFormatName(formatName);     return iter.hasNext();   }   }