Here you can find the source of getResourceAsStream(Class> clazz, String resourceName)
public static InputStream getResourceAsStream(Class<?> clazz, String resourceName)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.InputStream; public class Main { public static InputStream getResourceAsStream(Class<?> clazz, String resourceName) { return clazz.getResourceAsStream(resourceName); }//from ww w . j a va 2s. c o m public static InputStream getResourceAsStream(Class<?> clazz, File file) { return getResourceAsStream(clazz, toResourceName(file)); } public static String toResourceName(File file) { return toResourceName(file.getPath()); } public static String toResourceName(String name) { return name.replaceAll("\\\\", "/"); } }