import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
/**
*
* @param pathImg 本地图片路径
* @return
*/
public boolean checkImage(String pathImg) {
BufferedImage image = null;
boolean valid =true;
try {
image= ImageIO.read(new File(pathImg));
if (image == null || image.getWidth() <= 0 || image.getHeight() <= 0) {
valid = false;
}
} catch(IOException ex) {
ex.printStackTrace();
valid=false;
}
return valid;
}
- 注意: 该方法适用的图片格式为 bmp/gif/jpg/png