Code example for File

Methods: toURI

0
 
	private static final Class<?>[] parameters = new Class<?>[] { URL.class };
	private static final Vector<URL> added = new Vector<URL>();
 
	public static void addFile(String s) throws IOException {
		File f = new File(s);
		addFile(f);
	} 
 
	public static void addFile(File f) throws IOException {
		addURL(f.toURI().toURL());
	} 
 
	public static void addURL(URL u) throws IOException {
		if (added.contains(u)) return;
		added.add(u);
		URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
		Class<?> sysclass = URLClassLoader.class;
		try { 
			Method method = sysclass.getDeclaredMethod("addURL", parameters);
			method.setAccessible(true);