Here you can find the source of getResourceAsStream(String resName, Object obj)
public static InputStream getResourceAsStream(String resName, Object obj) throws FileNotFoundException
//package com.java2s; /*/ Part of JayWormNET source code. (C) 2013 Andrey Bobkov (MEDVEDx64). Licensed under the Apache License, Version 2.0. /*/ import java.io.*; public class Main { public static InputStream getResourceAsStream(String resName, Object obj) throws FileNotFoundException { InputStream str = obj.getClass().getResourceAsStream(resName.startsWith("/") ? resName : "/" + resName); File file = new File(resName); if (file.exists()) return new FileInputStream(file); else if (str != null) return str; else// ww w. jav a 2s. c o m throw new FileNotFoundException("No such resource: " + resName); } }