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 = 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();
    }
}