Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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 = canReadExtension("foo"); // false
        b = canReadExtension("gif"); // true
        b = canReadExtension("giF"); // true
    }

    // Returns true if the specified file extension can be read
    public static boolean canReadExtension(String fileExt) {
        Iterator iter = ImageIO.getImageReadersBySuffix(fileExt);
        return iter.hasNext();
    }

}