org.dmonix.util.zip
Class ZipReader

java.lang.Object
  extended byorg.dmonix.util.zip.ZipReader

public class ZipReader
extends java.lang.Object

Class for reading/inflating entries in a ZIP file.

Copyright: Copyright (c) 2001

Company: dmonix.org

Version:
1.0
Author:
Peter Nerg

Method Summary
 void close()
          Close the zip file.
 java.util.zip.ZipEntry getEntry(java.lang.String name)
          Return the ZipEntry with the matching name
 boolean hasMoreElements()
          Check if there are more entries to fetch from the zip file
 ZipFileEntry nextEntry()
          Return the next entry in the opened zip file
static ZipReader openZipFile(java.io.File file)
          Open a stream to an existing zip file.
static ZipReader openZipFile(java.lang.String fileName)
          Open a stream to an existing zip file.
 int size()
          Returns the number of entries in the ZIP file.
 void unzip(java.util.zip.ZipEntry zipEntry, java.io.File path)
          Unzip a zip entry to the specified path.
 void unzip(java.util.zip.ZipEntry zipEntry, java.io.OutputStream ostream)
          Unzip a zip entry to the specified outputstream.
 void unzip(java.util.zip.ZipEntry zipEntry, java.lang.String path)
          Unzip a zip entry to the specified path.
 int unzipAll(java.io.File path)
          Unzip all entries in the zip file to the specified path.
 int unzipAll(java.lang.String path)
          Unzip all entries in the zip file to the specified path.
 boolean unzipNextEntry(java.io.File path)
          Unzip the next entry to the specified path.
 boolean unzipNextEntry(java.io.OutputStream ostream)
          Unzip the next zip entry to the specified outputstream.
 boolean unzipNextEntry(java.lang.String path)
          Unzip the next entry to the specified path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public void close()
           throws java.io.IOException
Close the zip file.

Throws:
java.io.IOException

size

public int size()
Returns the number of entries in the ZIP file.

Returns:
number of entries

getEntry

public java.util.zip.ZipEntry getEntry(java.lang.String name)
                                throws java.io.IOException
Return the ZipEntry with the matching name

Parameters:
name - Name of the ZipEntry
Returns:
The zip entry, null if not found
Throws:
java.io.IOException

hasMoreElements

public boolean hasMoreElements()
Check if there are more entries to fetch from the zip file

Returns:
boolean true/false

nextEntry

public ZipFileEntry nextEntry()
                       throws java.io.IOException
Return the next entry in the opened zip file

Returns:
The next entry, null if none
Throws:
java.io.IOException

openZipFile

public static ZipReader openZipFile(java.io.File file)
                             throws java.io.IOException
Open a stream to an existing zip file.

Parameters:
file - The zip file object
Returns:
An instance of ZipReader
Throws:
java.io.IOException

openZipFile

public static ZipReader openZipFile(java.lang.String fileName)
                             throws java.io.IOException
Open a stream to an existing zip file.

Parameters:
fileName - The zip file
Returns:
An instance of ZipReader
Throws:
java.io.IOException

unzip

public void unzip(java.util.zip.ZipEntry zipEntry,
                  java.io.File path)
           throws java.io.IOException
Unzip a zip entry to the specified path.
Any existing files will be overwritten.

Parameters:
zipEntry - The zip entry to inflate
path - The path where to deflate the entry
Throws:
java.io.IOException

unzip

public void unzip(java.util.zip.ZipEntry zipEntry,
                  java.io.OutputStream ostream)
           throws java.io.IOException
Unzip a zip entry to the specified outputstream.

Parameters:
zipEntry - The zip entry to inflate
ostream - The outputstream to write the deflated data to
Throws:
java.io.IOException

unzip

public void unzip(java.util.zip.ZipEntry zipEntry,
                  java.lang.String path)
           throws java.io.IOException
Unzip a zip entry to the specified path.
Any existing files will be overwritten.

Parameters:
zipEntry - The zip entry to inflate
path - The path where to deflate the entry
Throws:
java.io.IOException

unzipAll

public int unzipAll(java.io.File path)
             throws java.io.IOException
Unzip all entries in the zip file to the specified path.
Any existing files will be overwritten.

Parameters:
path - The path where to deflate the entries
Returns:
the amount of deflated files
Throws:
java.io.IOException

unzipAll

public int unzipAll(java.lang.String path)
             throws java.io.IOException
Unzip all entries in the zip file to the specified path.
Any existing files will be overwritten.

Parameters:
path - The path where to deflated the entries
Returns:
the amount of deflated files
Throws:
java.io.IOException

unzipNextEntry

public boolean unzipNextEntry(java.io.File path)
                       throws java.io.IOException
Unzip the next entry to the specified path.
Any existing files will be overwritten.
The method will make an implicit call to nextEntry()

Parameters:
path - The path where to deflate the entry
Returns:
true if ok, false if no more files
Throws:
java.io.IOException

unzipNextEntry

public boolean unzipNextEntry(java.io.OutputStream ostream)
                       throws java.io.IOException
Unzip the next zip entry to the specified outputstream.

Parameters:
ostream - The outputstream to write the deflated data to
Returns:
true if ok, false if no more files
Throws:
java.io.IOException

unzipNextEntry

public boolean unzipNextEntry(java.lang.String path)
                       throws java.io.IOException
Unzip the next entry to the specified path.
Any existing files will be overwritten.
The method will make an implicit call to nextEntry()

Parameters:
path - The path where to deflate the entry
Returns:
true if ok, false if no more files
Throws:
java.io.IOException


Copyright © 1998-2005 dmonix.org Peter Nerg, All Rights Reserved.