nl.knowledgeplaza.util
Class JarResources

java.lang.Object
  extended by nl.knowledgeplaza.util.JarResources

public class JarResources
extends java.lang.Object

Access all resources included in a Zip or Jar file. Per default the complete file is NOT kept in memory, but each resource is extracted separately. For better performance, the whole resource may be read into memory (cacheAll). If an InputStream is used, only one resource can be read (because InputStreams cannot be reversed), or all entries must be kept in memory (cacheAll).


Field Summary
static java.lang.String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
JarResources(java.io.File file)
           
JarResources(java.io.File file, boolean cacheAll)
           
JarResources(java.io.InputStream is, boolean cacheAll)
          creates a JarResources.
JarResources(java.lang.String jarFileName)
           
JarResources(java.lang.String jarFileName, boolean cacheAll)
           
 
Method Summary
 boolean getCacheAll()
          CacheAll
 byte[] getResource(java.lang.String name)
          Extracts a jar resource
 byte[] getResource2(java.lang.String name)
          Extracts a jar resource, IOException just returns null
 java.io.InputStream getResourceAsStream(java.lang.String name)
          Extracts a jar resource as a blob.
 java.io.InputStream getResourceAsStream2(java.lang.String name)
          Extracts a jar resource, IOException just returns null
 java.lang.String[] getResourceNames()
          Extracts a jar resource
 void setCacheAll(boolean value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final java.lang.String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values
Constructor Detail

JarResources

public JarResources(java.lang.String jarFileName)
             throws java.io.FileNotFoundException
Parameters:
jarFileName - a jar or zip filename
Throws:
java.io.FileNotFoundException

JarResources

public JarResources(java.lang.String jarFileName,
                    boolean cacheAll)
             throws java.io.FileNotFoundException
Parameters:
jarFileName - a jar or zip filename
cacheAll - read whole file into memory (uncompressed!)
Throws:
java.io.FileNotFoundException

JarResources

public JarResources(java.io.File file)
             throws java.io.FileNotFoundException
Parameters:
file - a jar or zip file
Throws:
java.io.FileNotFoundException

JarResources

public JarResources(java.io.File file,
                    boolean cacheAll)
             throws java.io.FileNotFoundException
Parameters:
file - a jar or zip file
cacheAll - read whole file into memory (uncompressed!)
Throws:
java.io.FileNotFoundException

JarResources

public JarResources(java.io.InputStream is,
                    boolean cacheAll)
creates a JarResources.

Parameters:
is - an jar or zip inputstream
cacheAll - read all in memory (this is required to be able to access multiple resources)
Method Detail

getCacheAll

public boolean getCacheAll()
CacheAll


setCacheAll

public void setCacheAll(boolean value)

getResourceNames

public java.lang.String[] getResourceNames()
                                    throws java.io.IOException
Extracts a jar resource

Parameters:
name - a resource name.
Throws:
java.io.IOException

getResource

public byte[] getResource(java.lang.String name)
                   throws java.io.IOException
Extracts a jar resource

Parameters:
name - a resource name.
Throws:
java.io.IOException

getResource2

public byte[] getResource2(java.lang.String name)
Extracts a jar resource, IOException just returns null

Parameters:
name - a resource name.

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
                                        throws java.io.IOException
Extracts a jar resource as a blob.

Parameters:
name - a resource name.
Throws:
java.io.IOException

getResourceAsStream2

public java.io.InputStream getResourceAsStream2(java.lang.String name)
Extracts a jar resource, IOException just returns null

Parameters:
name - a resource name.


Copyright © 2010 KnowledgePlaza. All Rights Reserved.