List of utility methods to do Resource Load
InputStream | getResourceAsStream(String name, Class> clzz) get Resource As Stream InputStream inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); if (inStream != null) { return inStream; ClassLoader c = clzz.getClassLoader(); if (c != null) { inStream = c.getResourceAsStream(name); if (inStream != null) { ... |
InputStream | getResourceAsStream(String path) Return the InputStream of the resource provided, following the #findResource(String) rules. ClassLoader cl = Thread.currentThread().getContextClassLoader();
return cl.getResourceAsStream(path);
|
InputStream | getResourceAsStream(String path, Class> caller) get Resource As Stream String resource = path; if (resource.startsWith(SLASH)) { resource = resource.substring(1); InputStream is = null; File file = new File(path); if (file.exists() && file.isFile()) { try { ... |
InputStream | getResourceAsStream(String path, ClassLoader cl) get Resource As Stream return cl.getResourceAsStream(path);
|
InputStream | getResourceAsStream(String path, ClassLoader loader) get Resource As Stream if (loader == null) { return null; InputStream in = loader.getResourceAsStream(path); if (in != null) { return in; return loader.getResourceAsStream(togglePath(path)); ... |
InputStream | getResourceAsStream(String relativeName, Class> clazz) Returns the input stream for the resource with the specified relative name. String newName = getAbsoluteResourceName(relativeName, clazz);
return getResourceAsStream(newName);
|
InputStream | getResourceAsStream(String res) get Resource As Stream return Object.class.getResourceAsStream(res); |
InputStream | getResourceAsStream(String resName, Object obj) get Resource As Stream InputStream str = obj.getClass().getResourceAsStream(resName.startsWith("/") ? resName : "/" + resName); File file = new File(resName); if (file.exists()) return new FileInputStream(file); else if (str != null) return str; else throw new FileNotFoundException("No such resource: " + resName); ... |
InputStream | getResourceAsStream(String resource, ClassLoader classLoader) get Resource As Stream InputStream returnValue = classLoader.getResourceAsStream(resource); if (null == returnValue) { returnValue = classLoader.getResourceAsStream("/" + resource); if (null != returnValue) { return returnValue; return null; ... |
InputStream | getResourceAsStream(String resource, ClassLoader classLoader) Returns a resource on the classpath as a Stream object. InputStream in = null; if (classLoader != null) in = classLoader.getResourceAsStream(resource); if (in == null) in = ClassLoader.getSystemResourceAsStream(resource); if (in == null) throw new IOException("Could not find resource " + resource); return in; ... |