de.enough.polish.util
Class ResourceStreamUtil

java.lang.Object
  extended by de.enough.polish.util.ResourceStreamUtil

public class ResourceStreamUtil
extends java.lang.Object

A convenience class for accessing resources.

Copyright Enough Software 2008

Author:
Robert Virkus, j2mepolish@enough.de

Method Summary
static byte[] getResourceAsByteArray(java.lang.String url)
          Retrieves a resource as a byte array.
static byte[] toByteArray(java.io.InputStream in)
          Retrieves a resource as a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getResourceAsByteArray

public static byte[] getResourceAsByteArray(java.lang.String url)
                                     throws java.io.IOException
Retrieves a resource as a byte array.

Parameters:
url - the URL of the resource within the JAR file, e.g. /resource.xml
Returns:
the resource as byte array
Throws:
java.io.IOException - when the resource could not be read

toByteArray

public static byte[] toByteArray(java.io.InputStream in)
                          throws java.io.IOException
Retrieves a resource as a byte array.

Parameters:
in - the input stream of the resource, the input stream will be closed automatically
Returns:
the resource as byte array
Throws:
java.io.IOException - when the resource could not be read