1 package com.simontuffs.onejar; 2 3 import java.io.IOException ; 4 import java.io.InputStream ; 5 import java.net.URL ; 6 import java.net.URLConnection ; 7 import java.net.URLStreamHandler ; 8 9 13 public class Handler extends URLStreamHandler { 14 15 19 public static String PROTOCOL = "onejar"; 20 21 protected int len = PROTOCOL.length()+1; 22 23 26 protected URLConnection openConnection(URL u) throws IOException { 27 final String resource = u.toString().substring(len); 28 return new URLConnection (u) { 29 public void connect() { 30 } 31 public InputStream getInputStream() { 32 JarClassLoader cl = Boot.getClassLoader(); 35 return cl.getByteStream(resource); 36 } 37 }; 38 } 39 40 } 41 | Popular Tags |