Java Image File Check isImage(File imgFile)

Here you can find the source of isImage(File imgFile)

Description

is Image

License

Open Source License

Declaration

public static boolean isImage(File imgFile) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import javax.imageio.ImageIO;

import java.awt.image.BufferedImage;
import java.io.*;

public class Main {

    public static boolean isImage(File imgFile) {
        try {// w  w  w  .  j  a  v  a 2 s  . c o  m
            BufferedImage image = ImageIO.read(imgFile);
            return image != null;
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
    }
}

Related

  1. isImage(File imageFile)
  2. isImage(File img)
  3. isImage(InputStream is)