Here you can find the source of getResourceAsStream(String name, Class clazz)
public static InputStream getResourceAsStream(String name, Class clazz)
//package com.java2s; import java.io.InputStream; public class Main { public static InputStream getResourceAsStream(String name, Class clazz) { ClassLoader loader;//from w w w . ja va2 s . c om // TODO - is this needed? ClassPathLoader is a GemFire service and // is not available in JGroups // try { // return ClassPathLoader.getLatest().getResourceAsStream(name); // } // catch (VirtualMachineError err) { // GemStoneAddition // // If this ever returns, rethrow the error. We're poisoned // // now, so don't let this thread continue. // throw err; // } // catch(Throwable t) { // } if (clazz != null) { try { loader = clazz.getClassLoader(); if (loader != null) { return loader.getResourceAsStream(name); } } catch (VirtualMachineError err) { // GemStoneAddition // If this ever returns, rethrow the error. We're poisoned // now, so don't let this thread continue. throw err; } catch (Throwable t) { } } try { loader = ClassLoader.getSystemClassLoader(); if (loader != null) { return loader.getResourceAsStream(name); } } catch (VirtualMachineError err) { // GemStoneAddition // If this ever returns, rethrow the error. We're poisoned // now, so don't let this thread continue. throw err; } catch (Throwable t) { } return null; } }