Class ZipResourceLoader

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

public class ZipResourceLoader extends Object
Loads files from a local or network zip archive.
Author:
fred
  • Constructor Details

    • ZipResourceLoader

      public ZipResourceLoader(URL p_JarUrl) throws IOException
      Creates a ZipResourceLoader that loads data from an URL.
      Parameters:
      p_JarUrl - URL to load files from.
      Throws:
      IOException - if there is an exception while loading the archive.
    • ZipResourceLoader

      public ZipResourceLoader(InputStream p_JarStream) throws IOException
      Creates a ZipResourceLoader that loads data from an InputStream.
      Throws:
      IOException
  • Method Details

    • getResourceAsStream

      public InputStream getResourceAsStream(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 URL getResource(String name) throws 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:
      MalformedURLException - If the URL is malformed.
    • getZipResource

      public ZipResourceLoader.ZipResource getZipResource(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(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 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(String[] args) throws Exception
      Diagnostic for the ZipResource class.
      Parameters:
      args - The command line arguments
      Throws:
      Exception - If anything whatsoever goes wrong. :-)