public class ResourceLoader extends Object
Resources may be retrieved as byte arrays, as String
s, as
InputStream
s, as AudioClip
s, as
Image
s, or as Properties
objects.
See ResourceManager
for a higher-level interface.
ResourceManager
Modifier and Type | Field and Description |
---|---|
protected Class |
clazz
The class object associated with this resource loader.
|
private ResourceDecoder |
decoder |
Constructor and Description |
---|
ResourceLoader(Class clazz)
Construct a new
ResourceLoader . |
Modifier and Type | Method and Description |
---|---|
AudioClip |
getResourceAsAudioClip(String path)
Retrieve a resource as an
AudioClip . |
Image |
getResourceAsImage(String path)
Retrieve a resource as an
Image . |
Properties |
getResourceAsProperties(String path)
Retrieve a resource as a
Properties object. |
InputStream |
getResourceAsStream(String path)
Retrieve a resource as a stream.
|
String |
getResourceAsString(String path)
Retrieve a resource as a
String . |
URL |
getResourceAsURL(String path)
Retrieve a resource as a URL.
|
private ResourceDecoder decoder
public ResourceLoader(Class clazz)
ResourceLoader
. A new resource loader is
created with a default input buffer size.public URL getResourceAsURL(String path)
path
- The location of the resource.URL
reference to the resource.public InputStream getResourceAsStream(String path) throws IOException
path
- The location of the resource.InputStream
from which the resource data may be
read.IOException
- If the resource was not found.public final String getResourceAsString(String path) throws IOException
String
. Retrieves the specified
resource, returning its data as a String
. It is assumed that
the resource contains printable text.path
- The location of the resource.IOException
- If an error occurred while reading the
resource's data.public final AudioClip getResourceAsAudioClip(String path)
AudioClip
. Retrieves the specified
resource, returning its data as an AudioClip
. It is assumed
that the resource contains valid audio data.path
- The location of the resource.public final Image getResourceAsImage(String path)
Image
. Retrieves the specified
resource, returning its data as an Image
. It is assumed that
the resource contains valid image data.path
- The location of the resource.public final Properties getResourceAsProperties(String path) throws IOException
Properties
object. Retrieves the
specified resource, returning its data as a Properties
object. It is assumed that the resource is a properly-formatted property
list.path
- The location of the resource.IOException
- If an error occurred while reading the
resource's data.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses