Here you can find the source of loadImage(String path)
public static Image loadImage(String path)
//package com.java2s; //License from project: Open Source License import javax.imageio.ImageIO; import java.awt.*; import java.io.File; import java.io.IOException; import java.util.HashMap; public class Main { private static HashMap<String, Image> cache = new HashMap<String, Image>(); public static Image loadImage(String path) { Image image = null;// w w w . j a v a 2 s .co m if (cache.containsKey(path)) { return cache.get(path); } try { image = ImageIO.read(new File(path)); if (!cache.containsKey(path)) { cache.put(path, image); } } catch (IOException e) { e.printStackTrace(); } return image; } }