/** * Find a class on the classpath (or die trying) * * @param name - the class to look for * @return - the class * @throws ClassNotFoundException Duh. */ public Class<?> classForName(String name) throws ClassNotFoundException { return classForName(name, getClassLoaders(null)); }
/** * Get a resource from the classpath * * @param resource - the resource to find * @return the stream or null */ public InputStream getResourceAsStream(String resource) { return getResourceAsStream(resource, getClassLoaders(null)); }
/** * Get a resource as a URL using the current class path * * @param resource - the resource to locate * @return the resource or null */ public URL getResourceAsURL(String resource) { return getResourceAsURL(resource, getClassLoaders(null)); }
public static URL getResourceURL(ClassLoader loader, String resource) throws IOException { URL url = classLoaderWrapper.getResourceAsURL(resource, loader); if (url == null) { throw new IOException("Could not find resource " + resource); } return url; }
public static InputStream getResourceAsStream(ClassLoader loader, String resource) throws IOException { InputStream in = classLoaderWrapper.getResourceAsStream(resource, loader); if (in == null) { throw new IOException("Could not find resource " + resource); } return in; }
/** * Loads a class * * @param className - the class to fetch * @return The loaded class * @throws ClassNotFoundException If the class cannot be found (duh!) */ public static Class<?> classForName(String className) throws ClassNotFoundException { return classLoaderWrapper.classForName(className); }
/** * Returns the URL of the resource on the classpath * * @param loader The classloader used to fetch the resource * @param resource The resource to find * @return The resource * @throws java.io.IOException If the resource cannot be found or read */ public static URL getResourceURL(ClassLoader loader, String resource) throws IOException { URL url = classLoaderWrapper.getResourceAsURL(resource, loader); if (url == null) { throw new IOException("Could not find resource " + resource); } return url; }
/** * Returns a resource on the classpath as a Stream object * * @param loader The classloader used to fetch the resource * @param resource The resource to find * @return The resource * @throws java.io.IOException If the resource cannot be found or read */ public static InputStream getResourceAsStream(ClassLoader loader, String resource) throws IOException { InputStream in = classLoaderWrapper.getResourceAsStream(resource, loader); if (in == null) { throw new IOException("Could not find resource " + resource); } return in; }
public static Class<?> classForName(String className) throws ClassNotFoundException { return classLoaderWrapper.classForName(className); }
/** * Get a resource from the classpath, starting with a specific class loader * * @param resource - the resource to find * @param classLoader - the first class loader to try * @return the stream or null */ public InputStream getResourceAsStream(String resource, ClassLoader classLoader) { return getResourceAsStream(resource, getClassLoaders(classLoader)); }
/** * Find a class on the classpath, starting with a specific classloader (or die trying) * * @param name - the class to look for * @param classLoader - the first classloader to try * @return - the class * @throws ClassNotFoundException Duh. */ public Class<?> classForName(String name, ClassLoader classLoader) throws ClassNotFoundException { return classForName(name, getClassLoaders(classLoader)); }
/** * Get a resource from the classpath, starting with a specific class loader * * @param resource - the resource to find * @param classLoader - the first classloader to try * @return the stream or null */ public URL getResourceAsURL(String resource, ClassLoader classLoader) { return getResourceAsURL(resource, getClassLoaders(classLoader)); }
/** * Returns the URL of the resource on the classpath * * @param resource The resource to find * @return The resource * @throws java.io.IOException If the resource cannot be found or read */ public static URL getResourceURL(String resource) throws IOException { return classLoaderWrapper.getResourceAsURL(resource); }
/** * Returns a resource on the classpath as a Stream object * * @param loader The classloader used to fetch the resource * @param resource The resource to find * @return The resource * @throws java.io.IOException If the resource cannot be found or read */ public static InputStream getResourceAsStream(ClassLoader loader, String resource) throws IOException { InputStream in = classLoaderWrapper.getResourceAsStream(resource, loader); if (in == null) throw new IOException("Could not find resource " + resource); return in; }
/** * Loads a class * * @param className - the class to fetch * @return The loaded class * @throws ClassNotFoundException If the class cannot be found (duh!) */ public static Class classForName(String className) throws ClassNotFoundException { return classLoaderWrapper.classForName(className); }
public InputStream getResourceAsStream(String resource, ClassLoader classLoader) { return getResourceAsStream(resource, getClassLoaders(classLoader)); }
public Class<?> classForName(String name) throws ClassNotFoundException { return classForName(name, getClassLoaders(null)); }
public URL getResourceAsURL(String resource) { return getResourceAsURL(resource, getClassLoaders(null)); }
/** * Returns the URL of the resource on the classpath * * @param loader The classloader used to fetch the resource * @param resource The resource to find * @return The resource * @throws java.io.IOException If the resource cannot be found or read */ public static URL getResourceURL(ClassLoader loader, String resource) throws IOException { URL url = classLoaderWrapper.getResourceAsURL(resource, loader); if (url == null) throw new IOException("Could not find resource " + resource); return url; }
/** * Get a resource from the classpath * * @param resource - the resource to find * @return the stream or null */ public InputStream getResourceAsStream(String resource) { return getResourceAsStream(resource, new ClassLoader[]{ defaultClassLoader, Thread.currentThread().getContextClassLoader(), getClass().getClassLoader(), ClassLoader.getSystemClassLoader() }); }