Here you can find the source of loadResource(String file)
public static Image loadResource(String file)
//package com.java2s; //License from project: Apache License import java.awt.Image; import java.io.IOException; import java.io.InputStream; import javax.imageio.ImageIO; public class Main { public static Image loadResource(String file) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream input = classLoader.getResourceAsStream(file); try {/*from w w w .ja va 2s. com*/ return ImageIO.read(input); } catch (IOException e) { e.printStackTrace(); } return null; } }