org.basex.io
Class Zip

java.lang.Object
  extended by org.basex.core.Proc
      extended by org.basex.io.Zip

public final class Zip
extends Proc

Contains methods for zipping and unzipping archives.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
 
Fields inherited from class org.basex.core.Proc
listen, updating
 
Constructor Summary
Zip(IO file)
          Constructor.
 
Method Summary
static byte[] getEntry(java.util.zip.ZipInputStream in, java.lang.String entry)
          Returns the contents of the specified entry, or null.
protected  double prog()
          Returns a progress value (0 - 1).
 byte[] read(java.lang.String path)
          Returns the contents of a zip file entry.
 void unzip(IOFile target)
          Unzips the archive to the specified directory.
 void zip(IOFile root, StringList files)
          Zips the specified files.
 
Methods inherited from class org.basex.core.Proc
abort, checkStop, databases, det, detail, listen, proc, progress, registered, registered, startTimeout, stop, stopTimeout, tit, title
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Zip

public Zip(IO file)
Constructor.

Parameters:
file - archive file
Method Detail

read

public byte[] read(java.lang.String path)
            throws java.io.IOException
Returns the contents of a zip file entry.

Parameters:
path - file to be read
Returns:
resulting byte array
Throws:
java.io.IOException - I/O exception

unzip

public void unzip(IOFile target)
           throws java.io.IOException
Unzips the archive to the specified directory.

Parameters:
target - target path
Throws:
java.io.IOException - I/O exception

zip

public void zip(IOFile root,
                StringList files)
         throws java.io.IOException
Zips the specified files.

Parameters:
root - root directory
files - files to add
Throws:
java.io.IOException - I/O exception

prog

protected double prog()
Description copied from class: Proc
Returns a progress value (0 - 1). Can be overwritten to give more detailed information.

Overrides:
prog in class Proc
Returns:
header information

getEntry

public static byte[] getEntry(java.util.zip.ZipInputStream in,
                              java.lang.String entry)
                       throws java.io.IOException
Returns the contents of the specified entry, or null.

Parameters:
in - input stream
entry - entry to be found
Returns:
entry
Throws:
java.io.IOException - I/O exception