Here you can find the source of getResourceAsStream(String name, Class clazz)
public static InputStream getResourceAsStream(String name, Class clazz)
//package com.java2s; //License from project: LGPL import java.io.*; public class Main { public static InputStream getResourceAsStream(String name, Class clazz) { ClassLoader loader;//from w ww .ja va2 s.c om InputStream retval = null; try { loader = Thread.currentThread().getContextClassLoader(); if (loader != null) { retval = loader.getResourceAsStream(name); if (retval != null) return retval; } } catch (Throwable t) { } if (clazz != null) { try { loader = clazz.getClassLoader(); if (loader != null) { retval = loader.getResourceAsStream(name); if (retval != null) return retval; } } catch (Throwable t) { } } try { loader = ClassLoader.getSystemClassLoader(); if (loader != null) { return loader.getResourceAsStream(name); } } catch (Throwable t) { } return retval; } }