com.l2fprod.util
Class ZipResourceLoader

java.lang.Object
  extended by com.l2fprod.util.ZipResourceLoader

public class ZipResourceLoader
extends java.lang.Object

Loads files from a local or network zip archive.

Author:
fred

Nested Class Summary
 class ZipResourceLoader.ZipResource
          A class that represents a file contained in a zip archive.
 
Constructor Summary
ZipResourceLoader(java.io.InputStream p_JarStream)
          Creates a ZipResourceLoader that loads data from an InputStream.
ZipResourceLoader(java.net.URL p_JarUrl)
          Creates a ZipResourceLoader that loads data from an URL.
 
Method Summary
 void dump()
          A debugging method.
 java.util.Enumeration entries()
          Gets the files contained in this zip archive.
 java.net.URL getResource(java.lang.String name)
          Gets the URL of a file in the archive.
 java.io.InputStream getResourceAsStream(java.lang.String name)
          Opens an InputStream from a file contained in the archive.
 ZipResourceLoader.ZipResource getZipResource(java.lang.String name)
          Gets a ZipResource representing the file.
 ZipResourceLoader.ZipResource getZipResource(java.net.URL name)
          Gets a ZipResource representing the file.
static void main(java.lang.String[] args)
          Diagnostic for the ZipResource class.
 void release()
          Releases the resources claimed by this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipResourceLoader

public ZipResourceLoader(java.net.URL p_JarUrl)
                  throws java.io.IOException
Creates a ZipResourceLoader that loads data from an URL.

Parameters:
p_JarUrl - URL to load files from.
Throws:
java.io.IOException - if there is an exception while loading the archive.

ZipResourceLoader

public ZipResourceLoader(java.io.InputStream p_JarStream)
                  throws java.io.IOException
Creates a ZipResourceLoader that loads data from an InputStream.

Throws:
java.io.IOException
Method Detail

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Opens an InputStream from a file contained in the archive.

Parameters:
name - Name of the file to retrieve.
Returns:
An input stream from the file.

getResource

public java.net.URL getResource(java.lang.String name)
                         throws java.net.MalformedURLException
Gets the URL of a file in the archive.

Parameters:
name - Name of the file to retrieve.
Returns:
The URL of the file.
Throws:
java.net.MalformedURLException - If the URL is malformed.

getZipResource

public ZipResourceLoader.ZipResource getZipResource(java.lang.String name)
Gets a ZipResource representing the file.

Parameters:
name - The name of the file to retrieve.
Returns:
The ZipResource representing the file

getZipResource

public ZipResourceLoader.ZipResource getZipResource(java.net.URL name)
Gets a ZipResource representing the file.

Parameters:
name - The URL of the resource to retrieve.
Returns:
The ZipResource representing the file.

entries

public java.util.Enumeration entries()
Gets the files contained in this zip archive.

Returns:
An Enumeration of the files in this archive.

dump

public void dump()
A debugging method.


release

public void release()
Releases the resources claimed by this object.


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Diagnostic for the ZipResource class.

Parameters:
args - The command line arguments
Throws:
java.lang.Exception - If anything whatsoever goes wrong. :-)