Java examples for 2D Graphics:Image
get Image From Resource
//package com.java2s; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class Main { public static BufferedImage getImageFromResource(String name) { BufferedImage img = null; String path = ClassLoader.getSystemResource("").getFile(); path = path.substring(0, path.length() - 4); path += "res/img/" + name; try {/*from ww w.j a va2 s.c o m*/ img = ImageIO.read(new File(path)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return img; } }