01 package gate.util.protocols.classpath;
02
03 import java.io.FileNotFoundException;
04 import java.net.*;
05
06 import gate.Gate;
07
08 /**
09 * The handler for the "classpath://" URLs.
10 * All this class does is to transparently transform a "classpath://" URL into
11 * an URL of the according type and forward all requests through it.
12 */
13 public class Handler extends URLStreamHandler {
14
15 protected URLConnection openConnection(URL u) throws java.io.IOException {
16 URL actualURL = Gate.getClassLoader().getResource(u.getPath());// Handler.class.getResource(u.getPath());
17 if(actualURL == null) throw new FileNotFoundException(u.toExternalForm());
18 return actualURL.openConnection();
19 }
20 }
|