/** * Adds additional file or path to classpath during runtime. * @see #addUrlToClassPath(java.net.URL, ClassLoader) */ public static void addFileToClassPath(File path, ClassLoader classLoader) { try { addUrlToClassPath(FileUtil.toURL(path), classLoader); } catch (MalformedURLException muex) { throw new IllegalArgumentException("Invalid path: " + path, muex); } }
/** * @see #findClass(String, java.net.URL[], ClassLoader) */ public static Class findClass(String className, File[] classPath, ClassLoader parent) { URL[] urls = new URL[classPath.length]; for (int i = 0; i < classPath.length; i++) { File file = classPath[i]; try { urls[i] = FileUtil.toURL(file); } catch (MalformedURLException ignore) { } } return findClass(className, urls, parent); }
File file = (File) value; try { return FileUtil.toURL(file); } catch (MalformedURLException muex) { throw new TypeConversionException(value, muex);
File file = (File) value; try { return FileUtil.toURL(file); } catch (MalformedURLException muex) { throw new TypeConversionException(value, muex);
FileUtil.writeString(resourceFile, "RESOURCE CONTENT"); resourceFile.deleteOnExit(); URL[] urls = new URL[] {FileUtil.toURL(tempRoot)}; assertEquals(res, FileUtil.toURL(resourceFile)); assertEquals(res, FileUtil.toURL(resourceFile)); ecl.addLoaderOnlyRules("pckg.data"); res = ecl.getResource("pckg/data"); assertEquals(res, FileUtil.toURL(resourceFile)); ecl.addParentOnlyRules("pckg.data"); res = ecl.getResource("pckg/data"); ecl.addLoaderOnlyRules("pckg/data"); res = ecl.getResource("pckg/data"); assertEquals(res, FileUtil.toURL(resourceFile)); ecl.addParentOnlyRules("pckg.data"); res = ecl.getResource("pckg/data");
public static URL[] toUrls(File... files) { URL[] urls = new URL[files.length]; for (int i = 0; i < urls.length; i++) { File file = files[i]; try { urls[i] = FileUtil.toURL(file); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } } return urls; }
File file = (File) value; try { return FileUtil.toURL(file); } catch (MalformedURLException muex) { throw new TypeConversionException(value, muex);