Get a resource from the GATE ClassLoader. The return value is a java.net.URL that can be used to retrieve the contents of the resource.
(String resourceName)
| 386 | * resource. |
| 387 | */ |
| 388 | public static URL getResource(String resourceName) { |
| 389 | // Strip any leading '/' |
| 390 | if(resourceName.charAt(0) == '/') { |
| 391 | resourceName = resourceName.substring(1); |
| 392 | } |
| 393 | |
| 394 | ClassLoader gcl = Gate.getClassLoader(); |
| 395 | if(gcl == null) { |
| 396 | // if the GATE ClassLoader has not been initialised yet (i.e. this |
| 397 | // method was called before Gate.init) then fall back to the current |
| 398 | // classloader |
| 399 | return Files.class.getClassLoader().getResource(resourceName); |
| 400 | } |
| 401 | else { |
| 402 | // if we can, get the resource through the GATE ClassLoader to allow |
| 403 | // loading of resources from plugin JARs as well as gate.jar |
| 404 | return gcl.getResource(resourceName); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | /** |
| 409 | * Get a resource from the GATE resources directory. The return value is a |