Here you can find the source of getResourceAsStream(Class clazz, String name)
Parameter | Description |
---|---|
clazz | a class to try the class loader of |
name | the resource name |
public static InputStream getResourceAsStream(Class clazz, String name)
//package com.java2s; //License from project: Apache License import java.io.InputStream; public class Main { /**//from w ww .j ava2s. c om * Load a resource from the classpath, first trying the thread context * class loader, then the class loader of the given class. * @param clazz a class to try the class loader of * @param name the resource name * @return an input stream for reading the resource, * or null if not found */ public static InputStream getResourceAsStream(Class clazz, String name) { InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); if (in == null) { in = clazz.getResourceAsStream(name); } return in; } }