Groovy Documentation

groovy.org.codenarc.util.io
[Groovy] Class ClassPathResource

java.lang.Object
  groovy.org.codenarc.util.io.ClassPathResource
All Implemented Interfaces:
Resource

class ClassPathResource

A Resource implementation for resources available on the classpath.

This class also provides a static InputStream getInputStream(String path) convenience method.

This is an internal class and its API is subject to change.

Authors:
Chris Mair


Property Summary
String path

 
Constructor Summary
ClassPathResource(String path)

Construct a new ClassPathResource

path:
- the path to the resource (file).

 
Method Summary
boolean exists()

@return true only if this resource exists and is accessible

static InputStream getInputStream(String path)

Convenience method to open an InputStream on the specified resource path relative the classpath

path:
- the path to the resource (file).

InputStream getInputStream()

Open an InputStream on the classpath resource path

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Property Detail

path

final String path


 
Constructor Detail

ClassPathResource

ClassPathResource(String path)
Construct a new ClassPathResource
path:
- the path to the resource (file). The path is relative to the classpath, by default, but may be optionally prefixed by any of the valid java.net.URL prefixes, such as "file:" (to load from a relative or absolute path on the filesystem), or "http:". The path must not be empty or null.


 
Method Detail

exists

boolean exists()
Returns:
true only if this resource exists and is accessible


getInputStream

static InputStream getInputStream(String path)
Convenience method to open an InputStream on the specified resource path relative the classpath
path:
- the path to the resource (file). The path is relative to the classpath, by default, but may be optionally prefixed by any of the valid java.net.URL prefixes, such as "file:" (to load from a relative or absolute path on the filesystem), or "http:". The path must not be empty or null.
throws:
IOException - if an error occurs opening the InputStream


getInputStream

InputStream getInputStream()
Open an InputStream on the classpath resource path
throws:
IOException - if an error occurs opening the InputStream


 

Groovy Documentation