MCPcopy Create free account
hub / github.com/GateNLP/gate-core / getResourceAsStream

Method getResourceAsStream

src/main/java/gate/util/Files.java:347–367  ·  view source on GitHub ↗

Get a resource from the GATE ClassLoader as an InputStream.

(String resourceName)

Source from the content-addressed store, hash-verified

345 /** Get a resource from the GATE ClassLoader as an InputStream.
346 */
347 public static InputStream getResourceAsStream(String resourceName)
348 throws IOException {
349 // Strip any leading '/'
350 if(resourceName.charAt(0) == '/') {
351 resourceName = resourceName.substring(1);
352 }
353
354 ClassLoader gcl = Gate.getClassLoader();
355 if(gcl == null) {
356 // if the GATE ClassLoader has not been initialised yet (i.e. this
357 // method was called before Gate.init) then fall back to the current
358 // classloader
359 return Files.class.getClassLoader().getResourceAsStream(resourceName);
360 }
361 else {
362 // if we can, get the resource through the GATE ClassLoader to allow
363 // loading of resources from plugin JARs as well as gate.jar
364 return gcl.getResourceAsStream(resourceName);
365 }
366 //return ClassLoader.getSystemResourceAsStream(resourceName);
367 } // getResourceAsStream(String)
368
369 /** Get a resource from the GATE resources directory as an InputStream.
370 * The resource name should be relative to <code>resourcePath</code> which

Callers 4

getResourceAsStringMethod · 0.95
fillInResInfosMethod · 0.80

Calls 2

getClassLoaderMethod · 0.95
charAtMethod · 0.80

Tested by

no test coverage detected