Here you can find the source of loadImage(URL resource)
public static BufferedImage loadImage(URL resource)
//package com.java2s; //License from project: Open Source License import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.net.URL; public class Main { public static BufferedImage loadImage(URL resource) { BufferedImage image = null; try {/*w w w . j a v a2s . com*/ image = ImageIO.read(resource); } catch (IOException e) { } return image; } public static BufferedImage loadImage(File f) { BufferedImage image = null; try { image = ImageIO.read(f); } catch (IOException e) { } return image; } }