List of utility methods to do Resource Load
List | getResourcesFromJarFile(File file, String resName) get Resources From Jar File List<String> retval = new ArrayList<String>(); try { ZipFile zf = new ZipFile(file); Enumeration e = zf.entries(); while (e.hasMoreElements()) { ZipEntry ze = (ZipEntry) e.nextElement(); String entry = ze.getName(); if (entry.startsWith(resName)) { ... |
Collection | getResourcesFromJarFile(final File file, final Pattern pattern) Gets the resources from jar file. final ArrayList<String> retval = new ArrayList<String>(); ZipFile zf; try { zf = new ZipFile(file); } catch (final ZipException e) { throw new Error(e); } catch (final IOException e) { throw new Error(e); ... |
Map | getResourcesFromZip(final byte[] barContent) get Resources From Zip final Map<String, byte[]> resources = new HashMap<String, byte[]>(); final InputStream in = new ByteArrayInputStream(barContent); final ZipInputStream zis = new ZipInputStream(in); ZipEntry zipEntry = null; while ((zipEntry = zis.getNextEntry()) != null) { if (!zipEntry.isDirectory()) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); int c; ... |
long | getResourceSize(ClassLoader classLoader, String path) get Resource Size final InputStream is = classLoader.getResourceAsStream(path); try { long n = 0; while (is.read() >= 0) { n++; return n; } finally { ... |
InputStream | getResourceStream(Class> clazz, String resourceName) Returns a resource as a stream by checking: 1. String cpResourceName = null; if (!resourceName.startsWith("/")) { cpResourceName = "/" + resourceName; } else { cpResourceName = resourceName; InputStream is = clazz.getResourceAsStream(cpResourceName); if (is == null) { ... |
InputStream | getResourceStream(final String resource) get Resource Stream return getClassLoader().getResourceAsStream(resource);
|
InputStream | getResourceStream(String className, ClassLoader classLoader) Gets the input stream from a class file. return classLoader.getResourceAsStream(className.replace('.', '/') + ".class"); |
InputStream | getResourceStream(String name) Resources are those stored in the class path (e.g., src/main/resources). ClassLoader loader = Thread.currentThread().getContextClassLoader();
return loader.getResourceAsStream(name);
|
InputStream | getResourceStream(String pathToResource) get Resource Stream try { return Class.forName("org.smartfrog.tools.eclipse.core.CoreUtilities") .getResourceAsStream(pathToResource); } catch (ClassNotFoundException e) { return null; |
InputStream | getResourceStream(String resource, Class> root) Load a resource as a stream String fullResourceName = resource; InputStream istream = root.getResourceAsStream(fullResourceName); if (istream == null && !resource.startsWith("/")) { fullResourceName = "/" + resource; istream = root.getResourceAsStream(fullResourceName); if (istream == null && !resource.startsWith("/")) { fullResourceName = "/" + resource; istream = root.getResourceAsStream(fullResourceName); ... |