Wednesday, December 24, 2014

To list ImageIO supported read/write file format on your system

Example to list suffixes, format names and MIME types of supported image format on your system, by ImageIO, for read and write.

package javasupportedimageformat;

import javax.imageio.ImageIO;

/**
 *
 * @web http://java-buddy.blogspot.com
 */
public class JavaSupportedImageFormat {

    public static void main(String[] args) {
        
        //reader support
        System.out.println("ImageIO reader supported file suffixes:");
        String readerFileSuffixes[] = ImageIO.getReaderFileSuffixes();
        for(String f : readerFileSuffixes){
            System.out.println(f);
        }
        System.out.println();
        
        System.out.println("ImageIO reader supported format names:");
        String readerFormatNames[] = ImageIO.getReaderFormatNames();
        for(String f : readerFormatNames){
            System.out.println(f);
        }
        System.out.println();
        
        System.out.println("ImageIO reader supported MIME types:");
        String readerMIMETypes[] = ImageIO.getReaderMIMETypes();
        for(String f : readerMIMETypes){
            System.out.println(f);
        }
        System.out.println();
        
        //writer support
        System.out.println("ImageIO writer supported file suffixes:");
        String writerFileSuffixes[] = ImageIO.getWriterFileSuffixes();
        for(String f : writerFileSuffixes){
            System.out.println(f);
        }
        System.out.println();
        
        System.out.println("ImageIO writer supported format names:");
        String writerFormatNames[] = ImageIO.getWriterFormatNames();
        for(String f : writerFormatNames){
            System.out.println(f);
        }
        System.out.println();
        
        System.out.println("ImageIO writer supported MIME types:");
        String writerMIMETypes[] = ImageIO.getWriterMIMETypes();
        for(String f : writerMIMETypes){
            System.out.println(f);
        }
        System.out.println();
    }
    
}

No comments:

Post a Comment