Package com.l2fprod.util
Class ZipResourceLoader
- java.lang.Object
-
- com.l2fprod.util.ZipResourceLoader
-
public class ZipResourceLoader extends java.lang.ObjectLoads files from a local or network zip archive.- Author:
- fred
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classZipResourceLoader.ZipResourceA class that represents a file contained in a zip archive.
-
Constructor Summary
Constructors Constructor Description 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddump()A debugging method.java.util.Enumerationentries()Gets the files contained in this zip archive.java.net.URLgetResource(java.lang.String name)Gets the URL of a file in the archive.java.io.InputStreamgetResourceAsStream(java.lang.String name)Opens an InputStream from a file contained in the archive.ZipResourceLoader.ZipResourcegetZipResource(java.lang.String name)Gets a ZipResource representing the file.ZipResourceLoader.ZipResourcegetZipResource(java.net.URL name)Gets a ZipResource representing the file.static voidmain(java.lang.String[] args)Diagnostic for the ZipResource class.voidrelease()Releases the resources claimed by this object.
-
-
-
Constructor Detail
-
ZipResourceLoader
public ZipResourceLoader(java.net.URL p_JarUrl) throws java.io.IOExceptionCreates 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.IOExceptionCreates 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.MalformedURLExceptionGets 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.ExceptionDiagnostic for the ZipResource class.- Parameters:
args- The command line arguments- Throws:
java.lang.Exception- If anything whatsoever goes wrong. :-)
-
-