Here you can find the source of loadImage(File file)
public static BufferedImage loadImage(File file) throws IOException
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static BufferedImage loadImage(File file) throws IOException { final FileInputStream fis = new FileInputStream(file); try {//w w w. j a v a 2 s. com final BufferedImage bufferedImage = ImageIO.read(fis); if (bufferedImage == null) { throw new IOException("ImageIO.read returned null for " + file); } return bufferedImage; } finally { fis.close(); } } }