public final class Resource extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Resource.NotFoundException
Thrown to indicate that a resource can't be found.
|
| Modifier and Type | Method and Description |
|---|---|
void |
copyTo(OutputStream out)
Copies the content of this resource to the specified stream.
|
void |
copyTo(Writer out,
Charset charset)
Copies the content of this resource to the specified stream.
|
boolean |
equals(Object o) |
static Resource |
find(String name)
Finds and returns the resource having the given name using the
context class loader.
|
static Resource |
find(String name,
Class<?> contextClass)
Finds and returns the resource having the given name (relative to
the specified class).
|
URL |
getURL()
Returns this resource's
URL. |
int |
hashCode() |
byte[] |
read()
Reads and returns this resource's content as a
byte[]. |
String |
read(Charset charset)
Reads and returns this resource's content as a
String. |
List<String> |
readLines(Charset charset)
Reads and returns all this resource's lines.
|
String |
toString() |
public static Resource find(String name)
null, the class
loader that loaded this class will be used instead.name - the resource's name.NullPointerException - if name is null.Resource.NotFoundException - if the resource can't be found.public static Resource find(String name, Class<?> contextClass)
name - the resource's name.contextClass - the context class.NullPointerException - if name is null.Resource.NotFoundException - if the resource can't be found.public URL getURL()
URL.URL.public void copyTo(OutputStream out) throws IOException
out - the stream to copy to.NullPointerException - if out is null.IOException - if an I/O error occurs during the process.public void copyTo(Writer out, Charset charset) throws IOException
out - the stream to copy to.charset - the charset to use.NullPointerException - if one of the arguments is null.IOException - if an I/O error occurs during the process.public byte[] read()
throws IOException
byte[].IOException - if an I/O error occurs during the process.public String read(Charset charset) throws IOException
String.charset - the charset to use.NullPointerException - if charset is null.IOException - if an I/O error occurs during the process.public List<String> readLines(Charset charset) throws IOException
List is immutable.charset - the charset to use.NullPointerException - if charset is null.IOException - if an I/O error occurs during the process.Copyright © 2012–2015. All rights reserved.