List of utility methods to do Resource Load
InputStream | getResourceAsStream(String filename) Get a resource as a stream. File f = new File(filename); try { if (f.exists()) { return new FileInputStream(f); } else { String fname = "classes" + File.separator + filename; f = new File(fname); if (f.exists()) { ... |
InputStream | getResourceAsStream(String filename) get Resource As Stream Thread currentThread = Thread.currentThread();
ClassLoader contextClassLoader = currentThread.getContextClassLoader();
return contextClassLoader.getResourceAsStream(filename);
|
InputStream | getResourceAsStream(String filePath) get Resource As Stream Thread.currentThread().getContextClassLoader(); InputStream inputstream = ClassLoader.getSystemResourceAsStream(filePath); if (inputstream == null) { inputstream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath); if (inputstream == null) { inputstream = new FileInputStream(new File(filePath)); return inputstream; |
InputStream | getResourceAsStream(String name) get Resource As Stream if (!name.startsWith("bio/gcat/")) name = "bio/gcat" + (name.startsWith("/") ? EMPTY : "/") + name; return localClassLoader.getResourceAsStream(name); |
InputStream | getResourceAsStream(String name) get Resource As Stream ClassLoader cl = getClassLoader(); if (cl == null) { return null; return cl.getResourceAsStream(name); |
InputStream | getResourceAsStream(String name) Returns an input stream from a file, given its name. return getContextClassLoader().getResourceAsStream(name);
|
InputStream | getResourceAsStream(String name) Load resource as stream if it is present somewhere in the classpath. InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); if (in == null) { throw new IOException("could not find " + name + " in classpath"); return in; |
InputStream | getResourceAsStream(String name, Class aClass) Return the input stream for the given name and class. if (isBlank(name)) { throw new IllegalArgumentException("Parameter name cannot be blank"); ; if (aClass == null) { throw new IllegalArgumentException("Parameter aClass is null"); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ... |
InputStream | getResourceAsStream(String name, Class clazz) get Resource As Stream ClassLoader loader; InputStream retval = null; try { loader = Thread.currentThread().getContextClassLoader(); if (loader != null) { retval = loader.getResourceAsStream(name); if (retval != null) return retval; ... |
InputStream | getResourceAsStream(String name, Class clazz) get Resource As Stream ClassLoader loader; if (clazz != null) { try { loader = clazz.getClassLoader(); if (loader != null) { return loader.getResourceAsStream(name); } catch (VirtualMachineError err) { ... |