Here you can find the source of getResourceAsStream(String filePath)
public static InputStream getResourceAsStream(String filePath) throws FileNotFoundException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; public class Main { public static InputStream getResourceAsStream(String filePath) throws FileNotFoundException { Thread.currentThread().getContextClassLoader(); InputStream inputstream = ClassLoader.getSystemResourceAsStream(filePath); if (inputstream == null) { inputstream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath); }/*from w ww . j a v a 2 s . co m*/ if (inputstream == null) { inputstream = new FileInputStream(new File(filePath)); } return inputstream; } }