List of utility methods to do Resource Load
InputStream | getResourceAsStream(Class> clazz, String fileName) get Resource As Stream InputStream is = clazz.getResourceAsStream(fileName); if (is == null) { is = clazz.getClassLoader().getResourceAsStream(fileName); if (is == null) { is = ClassLoader.getSystemResourceAsStream(fileName); if (is == null) { ... |
InputStream | getResourceAsStream(Class> clazz, String resource) get Resource As Stream return clazz == null ? ClassLoader.getSystemResourceAsStream(resource)
: clazz.getResourceAsStream(resource);
|
InputStream | getResourceAsStream(Class> clazz, String resourceName) get Resource As Stream return clazz.getResourceAsStream(resourceName);
|
InputStream | getResourceAsStream(Class> testClass, String resource) get Resource As Stream return testClass.getResourceAsStream(getResourcePath(testClass, resource));
|
InputStream | getResourceAsStream(final String fileName, ClassLoader classLoader) Gets a resource as InputStream. InputStream fileIn; fileIn = classLoader.getResourceAsStream(resolveFileName(fileName)); if (fileIn == null) { fileIn = classLoader.getResourceAsStream(resolveFileName("WEB-INF/classes/" + fileName)); if (fileIn == null) { fileIn = new FileInputStream(resolveFileName(fileName)); return fileIn; |
InputStream | getResourceAsStream(final String name) Get resource as stream in privileged mode. return Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
|
InputStream | getResourceAsStream(final String resourceName, final Class caller) Get the specified resource as a stream. final String resource; if (!resourceName.startsWith("/")) { final Package callerPackage = caller.getPackage(); if (callerPackage != null) { resource = callerPackage.getName().replace('.', '/') + '/' + resourceName; } else { resource = resourceName; return getResourceAsStream(resource, caller.getClassLoader()); } else { return getResourceAsStream(resourceName, caller.getClassLoader()); |
InputStream | getResourceAsStream(final String resourceName, final Class> caller) get Resource As Stream final String resource; if (resourceName.startsWith("/")) { resource = resourceName.substring(1); } else { final Package callerPackage = caller.getPackage(); if (callerPackage != null) { resource = callerPackage.getName().replace('.', '/') + '/' + resourceName; } else { ... |
InputStream | getResourceAsStream(Object context, String resourceName) get Resource As Stream Class<?> contextClass; if (context instanceof Class<?>) { contextClass = (Class<?>) context; } else { contextClass = context.getClass(); String fullResourceName = getFullyQualifiedResourceName(contextClass, resourceName); InputStream is = contextClass.getClassLoader().getResourceAsStream(fullResourceName); ... |
InputStream | getResourceAsStream(Object o, String resource) get Resource As Stream String newPath = ""; if (resource.startsWith("/")) { newPath = "/net/ages/alwb/utils/app/resources" + resource; } else { newPath = "/net/ages/alwb/utils/app/resources/" + resource; try { return o.getClass().getResourceAsStream(newPath); ... |