java.util.zip – Useful Resources

Java Zip – Useful Resources ”; Previous Next The following resources contain additional information on JAVA Please use them to get more in-depth knowledge on this topic. Useful Links on Java The JavaTM Tutorials − The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications. JavaTM 2 SDK, Standard Edition − Official site for JavaTM 2 SDK, Standard Edition Free Java Download − Download Java for your desktop computer now! Sun Developer Network − Sun Microsystem”s official website listing down all the API documentation, latest Java Technologies, Books and other resource. Useful Books on Java To enlist your site on this page, please drop an email to [email protected] Print Page Previous Next Advertisements ”;

java.util.zip – Inflater

java.util.zip – Inflater Class ”; Previous Next Introduction The java.util.zip.Inflater class provides support for general purpose decompression using the popular ZLIB compression library. The ZLIB compression library was initially developed as part of the PNG graphics standard and is not protected by patents. It is fully described in the specifications at the java.util.zip package description. Class Declaration Following is the declaration for java.util.zip.Inflater class − public class Inflater extends Object Constructors Sr.No. Constructor & Description 1 Inflater() Creates a new decompressor. 2 Inflater(boolean nowrap) Creates a new decompressor. Class Methods Sr.No. Method & Description 1 void end() Closes the decompressor and discards any unprocessed input. 2 boolean finished() Returns true if the end of the compressed data stream has been reached. 3 int getAdler() Returns the ADLER-32 value of the uncompressed data. 4 long getBytesRead() Returns the total number of compressed bytes input so far. 5 long getBytesWritten() Returns the total number of uncompressed bytes output so far. 6 int getRemaining() Returns the total number of bytes remaining in the input buffer. 7 int getTotalIn() Returns the total number of compressed bytes input so far. 8 int getTotalOut() Returns the total number of uncompressed bytes output so far. 9 int inflate(byte[] b) Uncompresses bytes into specified buffer. 10 int inflate(byte[] b, int off, int len) Uncompresses bytes into specified buffer. 11 boolean needsDictionary() Returns true if a preset dictionary is needed for decompression. 12 boolean needsInput() Returns true if no data remains in the input buffer. 13 void reset() Resets inflater so that a new set of input data can be processed. 14 void setDictionary(byte[] b) Sets the preset dictionary to the given array of bytes. 15 void setDictionary(byte[] b, int off, int len) Sets the preset dictionary to the given array of bytes. 16 void setInput(byte[] b) Sets input data for decompression. 17 void setInput(byte[] b, int off, int len) Sets input data for decompression. Methods Inherited This class inherits methods from the following classes − java.lang.Object Print Page Previous Next Advertisements ”;

java.util.zip – Exceptions

Java Zip – Exceptions ”; Previous Next Introduction The java.util.zip Exceptions contains the exceptions which can occur during zip/unzip operations. Interface Summary Sr.No. Exception & Description 1 DataFormatException Signals that a data format error has occurred. 2 ZipException Signals that a Zip exception of some sort has occurred. Print Page Previous Next Advertisements ”;

java.util.zip – CheckedInputStream

java.util.zip – CheckedInputStream Class ”; Previous Next Introduction The java.util.zip.CheckedInputStream class is an input stream that also maintains a checksum of the data being read. The checksum can then be used to verify the integrity of the input data. Class Declaration Following is the declaration for java.util.zip.CheckedInputStream class − public class CheckedInputStream extends FilterInputStream Constructors Sr.No. Constructor & Description 1 CheckedInputStream(InputStream in, Checksum cksum) Creates an input stream using the specified Checksum. Class Methods Sr.No. Method & Description 1 Checksum getChecksum() Returns the Checksum for this input stream. 2 int read() Reads a byte. 3 int read(byte[] buf, int off, int len) Reads into an array of bytes. 4 long skip(long n) Skips specified number of bytes of input. Methods Inherited This class inherits methods from the following classes − java.io.FilterInputStream java.lang.Object Print Page Previous Next Advertisements ”;

java.util.zip – Deflater

java.util.zip – Deflater Class ”; Previous Next Introduction The java.util.zip.Deflater class provides support for general purpose compression using the popular ZLIB compression library. The ZLIB compression library was initially developed as part of the PNG graphics standard and is not protected by patents. It is fully described in the specifications at the java.util.zip package description. Class Declaration Following is the declaration for java.util.zip.Deflater class − public class Deflater extends Object Fields Following are the fields for java.util.zip.Deflater class − static int BEST_COMPRESSION − Compression level for best compression. static int BEST_SPEED − Compression level for fastest compression. static int DEFAULT_COMPRESSION − Default compression level. static int DEFAULT_STRATEGY − Default compression strategy. static int DEFLATED − Compression method for the deflate algorithm (the only one currently supported). static int FILTERED − Compression strategy best used for data consisting mostly of small values with a somewhat random distribution. static int FULL_FLUSH − Compression flush mode used to flush out all pending output and reset the deflater. static int HUFFMAN_ONLY − Compression strategy for Huffman coding only. static int NO_COMPRESSION − Compression level for no compression. static int NO_FLUSH − Compression flush mode used to achieve best compression result. static int SYNC_FLUSH − Compression flush mode used to flush out all pending output; may degrade compression for some compression algorithms. Constructors Sr.No. Constructor & Description 1 Deflater() Creates a new compressor with the default compression level. 2 Deflater(int level) Creates a new compressor using the specified compression level. 3 Deflater(int level, boolean nowrap) Creates a new compressor using the specified compression level. Class Methods Sr.No. Method & Description 1 int deflate(byte[] b) Compresses the input data and fills specified buffer with compressed data. 2 int deflate(byte[] b, int off, int len) Compresses the input data and fills specified buffer with compressed data. 3 int deflate(byte[] b, int off, int len, int flush) Compresses the input data and fills the specified buffer with compressed data. 4 void end() Closes the compressor and discards any unprocessed input. 5 void finish() When called, indicates that compression should end with the current contents of the input buffer. 6 boolean finished() Returns true if the end of the compressed data output stream has been reached. 7 int getAdler() Returns the ADLER-32 value of the uncompressed data. 8 long getBytesRead() Returns the total number of uncompressed bytes input so far. 9 long getBytesWritten() Returns the total number of compressed bytes output so far. 10 int getTotalIn() Returns the total number of uncompressed bytes input so far. 11 int getTotalOut() Returns the total number of compressed bytes output so far. 12 boolean needsInput() Returns true if the input data buffer is empty and setInput() should be called in order to provide more input. 13 void reset() Resets deflater so that a new set of input data can be processed. 14 void setDictionary(byte[] b) Sets preset dictionary for compression. 15 void setDictionary(byte[] b, int off, int len) Sets preset dictionary for compression. 16 void setInput(byte[] b) Sets input data for compression. 17 void setInput(byte[] b, int off, int len) Sets input data for compression. 18 void setLevel(int level) Sets the current compression level to the specified value. 19 void setStrategy(int strategy) Sets the compression strategy to the specified value. Methods Inherited This class inherits methods from the following classes − java.lang.Object Print Page Previous Next Advertisements ”;

java.util.zip – DeflaterOutputStream

java.util.zip – DeflaterOutputStream Class ”; Previous Next Introduction The java.util.zip.DeflaterOutputStream class implements an output stream filter for compressing data in the “deflate” compression format. It is also used as the basis for other types of compression filters, such as GZIPOutputStream. Class Declaration Following is the declaration for java.util.zip.DeflaterOutputStream class − public class DeflaterOutputStream extends FilterOutputStream Fields Following are the fields for java.util.zip.DeflaterOutputStream class − protected byte[] buf − Output buffer for writing compressed data. protected Deflater def − Compressor for this stream. Constructors Sr.No. Constructor & Description 1 DeflaterOutputStream(OutputStream out) Creates a new output stream with a default compressor and buffer size. 2 DeflaterOutputStream(OutputStream out, boolean syncFlush) Creates a new output stream with a default compressor, a default buffer size and the specified flush mode. 3 DeflaterOutputStream(OutputStream out, Deflater def) Creates a new output stream with the specified compressor and a default buffer size. 4 DeflaterOutputStream(OutputStream out, Deflater def, boolean syncFlush) Creates a new output stream with the specified compressor, flush mode and a default buffer size. 5 DeflaterOutputStream(OutputStream out, Deflater def, int size) Creates a new output stream with the specified compressor and buffer size. 6 DeflaterOutputStream(OutputStream out, Deflater def, int size, boolean syncFlush) Creates a new output stream with the specified compressor, buffer size and flush mode. Class Methods Sr.No. Method & Description 1 void close() Writes remaining compressed data to the output stream and closes the underlying stream. 2 void finish() Finishes writing compressed data to the output stream without closing the underlying stream. 3 void flush() Flushes the compressed output stream. 4 void write(byte[] b, int off, int len) Writes an array of bytes to the compressed output stream. 5 void write(int b) Writes a byte to the compressed output stream. Methods Inherited This class inherits methods from the following classes − java.io.FilterOutputStream java.lang.Object Print Page Previous Next Advertisements ”;

java.util.zip – DeflaterInputStream

java.util.zip – DeflaterInputStream Class ”; Previous Next Introduction The java.util.zip.DeflaterInputStream class implements an input stream filter for compressing data in the “deflate” compression format. Class Declaration Following is the declaration for java.util.zip.DeflaterInputStream class − public class DeflaterInputStream extends FilterInputStream Fields Following are the fields for java.util.zip.DeflaterInputStream class − protected byte[] buf − Input buffer for reading compressed data. protected Deflater def − Compressor for this stream. Constructors Sr.No. Constructor & Description 1 DeflaterInputStream(InputStream in) Creates a new input stream with a default compressor and buffer size. 2 DeflaterInputStream(InputStream in, Deflater defl) Creates a new input stream with the specified compressor and a default buffer size. 3 DeflaterInputStream(InputStream in, Deflater defl, int bufLen) Creates a new input stream with the specified compressor and buffer size. Class Methods Sr.No. Method & Description 1 int available() Returns 0 after EOF has been reached, otherwise always return 1. 2 void close() Closes this input stream and its underlying input stream, discarding any pending uncompressed data. 3 int read() Reads a single byte of compressed data from the input stream. 4 int read(byte[] b, int off, int len) Reads compressed data into a byte array. 5 long skip(long n) Skips over and discards data from the input stream. Methods Inherited This class inherits methods from the following classes − java.io.FilterInputStream java.lang.Object Print Page Previous Next Advertisements ”;

java.util.zip – Quick Guide

Java Zip – Quick Guide ”; Previous Next java.util.zip – Adler32 The java.util.zip.Adler32 class is a class that can be used to compute the Adler-32 checksum of a data stream. An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed much faster. Class Declaration Following is the declaration for java.util.zip.Adler32 class − public class Adler32 extends Object implements Checksum Constructors Sr.No. Constructor & Description 1 Adler32() Creates a new Adler32 object. Class Methods Sr.No. Method & Description 1 long getValue() Returns the checksum value. 2 void reset() Resets the checksum to initial value. 3 void update(byte[] b) Updates the checksum with the specified array of bytes. 4 void update(byte[] b, int off, int len) Updates the checksum with the specified array of bytes. 5 void update(int b) Updates the checksum with the specified byte (the low eight bits of the argument b). Methods Inherited This class inherits methods from the following classes − java.lang.Object java.util.zip – CheckedInputStream Class Introduction The java.util.zip.CheckedInputStream class is an input stream that also maintains a checksum of the data being read. The checksum can then be used to verify the integrity of the input data. Class Declaration Following is the declaration for java.util.zip.CheckedInputStream class − public class CheckedInputStream extends FilterInputStream Constructors Sr.No. Constructor & Description 1 CheckedInputStream(InputStream in, Checksum cksum) Creates an input stream using the specified Checksum. Class Methods Sr.No. Method & Description 1 Checksum getChecksum() Returns the Checksum for this input stream. 2 int read() Reads a byte. 3 int read(byte[] buf, int off, int len) Reads into an array of bytes. 4 long skip(long n) Skips specified number of bytes of input. Methods Inherited This class inherits methods from the following classes − java.io.FilterInputStream java.lang.Object java.util.zip – CheckedOutputStream Class Introduction The java.util.zip.CheckedOutputStream class is an output stream that also maintains a checksum of the data being written. The checksum can then be used to verify the integrity of the output data. Class Declaration Following is the declaration for java.util.zip.CheckedOutputStream class − public class CheckedOutputStream extends FilterOutputStream Constructors Sr.No. Constructor & Description 1 CheckedOutputStream(OutputStream out, Checksum cksum) Creates an output stream with the specified Checksum. Class Methods Sr.No. Method & Description 1 Checksum getChecksum() Returns the Checksum for this output stream. 2 void write(byte[] b, int off, int len) Writes an array of bytes. 3 void write(int b) Writes a byte. Methods Inherited This class inherits methods from the following classes − java.io.FilterOutputStream java.lang.Object java.util.zip – CRC32 Class Introduction The java.util.zip.CRC32 class is a class that can be used to compute the CRC-32 of a data stream. Class Declaration Following is the declaration for java.util.zip.CRC32 class − public class CRC32 extends Object implements Checksum Constructors Sr.No. Constructor & Description 1 CRC32() Creates a new CRC32 object. Class Methods Sr.No. Method & Description 1 long getValue() Returns the CRC-32 value. 2 void reset() Resets the CRC-32 to initial value. 3 void update(byte[] b) Updates the CRC-32 checksum with the specified array of bytes. 4 void update(byte[] b, int off, int len) Updates the CRC-32 checksum with the specified array of bytes. 5 void update(int b) Updates the CRC-32 checksum with the specified byte (the low eight bits of the argument b). Methods Inherited This class inherits methods from the following classes − java.lang.Object java.util.zip – Deflater Class Introduction The java.util.zip.Deflater class provides support for general purpose compression using the popular ZLIB compression library. The ZLIB compression library was initially developed as part of the PNG graphics standard and is not protected by patents. It is fully described in the specifications at the java.util.zip package description. Class Declaration Following is the declaration for java.util.zip.Deflater class − public class Deflater extends Object Fields Following are the fields for java.util.zip.Deflater class − static int BEST_COMPRESSION − Compression level for best compression. static int BEST_SPEED − Compression level for fastest compression. static int DEFAULT_COMPRESSION − Default compression level. static int DEFAULT_STRATEGY − Default compression strategy. static int DEFLATED − Compression method for the deflate algorithm (the only one currently supported). static int FILTERED − Compression strategy best used for data consisting mostly of small values with a somewhat random distribution. static int FULL_FLUSH − Compression flush mode used to flush out all pending output and reset the deflater. static int HUFFMAN_ONLY − Compression strategy for Huffman coding only. static int NO_COMPRESSION − Compression level for no compression. static int NO_FLUSH − Compression flush mode used to achieve best compression result. static int SYNC_FLUSH − Compression flush mode used to flush out all pending output; may degrade compression for some compression algorithms. Constructors Sr.No. Constructor & Description 1 Deflater() Creates a new compressor with the default compression level. 2 Deflater(int level) Creates a new compressor using the specified compression level. 3 Deflater(int level, boolean nowrap) Creates a new compressor using the specified compression level. Class Methods Sr.No. Method & Description 1 int deflate(byte[] b) Compresses the input data and fills specified buffer with compressed data. 2 int deflate(byte[] b, int off, int len) Compresses the input data and fills specified buffer with compressed data. 3 int deflate(byte[] b, int off, int len, int flush) Compresses the input data and fills the specified buffer with compressed data. 4 void end() Closes the compressor and discards any unprocessed input. 5 void finish() When called, indicates that compression should end with the current contents of the input buffer. 6 boolean finished() Returns true if the end of the compressed data output stream has been reached. 7 int getAdler() Returns the ADLER-32 value of the uncompressed data. 8 long getBytesRead() Returns the total number of uncompressed bytes input so far. 9 long getBytesWritten() Returns the total number of compressed bytes output so far. 10 int getTotalIn() Returns the total number of uncompressed bytes input so far. 11 int getTotalOut() Returns the total number of compressed bytes output so far. 12 boolean needsInput() Returns true if the input data buffer is empty and setInput() should be called in order to provide more input. 13 void reset()

java.util.zip – InflaterOutputStream

java.util.zip – InflaterOutputStream Class ”; Previous Next Introduction The java.util.zip.InflaterOutputStream class implements an output stream filter for uncompressing data stored in the “deflate” compression format. Class Declaration Following is the declaration for java.util.zip.InflaterOutputStream class − public class InflaterOutputStream extends FilterOutputStream Fields Following are the fields for java.util.zip.InflaterOutputStream class − protected byte[] buf − Output buffer for writing uncompressed data. protected Inflater inf − Decompressor for this stream. Constructors Sr.No. Constructor & Description 1 InflaterOutputStream(OutputStream out) Creates a new output stream with a default decompressor and buffer size. 2 InflaterOutputStream(OutputStream out, Inflater infl) Creates a new output stream with the specified decompressor and a default buffer size. 3 InflaterOutputStream(OutputStream out, Inflater infl, int bufLen) Creates a new output stream with the specified decompressor and buffer size. Class Methods Sr.No. Method & Description 1 void close() Writes remaining compressed data to the output stream and closes the underlying stream. 2 void finish() Finishes writing uncompressed data to the output stream without closing the underlying stream. 3 void flush() Flushes this output stream, forcing any pending buffered output bytes to be written. 4 void write(byte[] b, int off, int len) Writes an array of bytes to the compressed output stream. 5 void write(int b) Writes a byte to the compressed output stream. Methods Inherited This class inherits methods from the following classes − java.io.FilterOutputStream java.lang.Object Print Page Previous Next Advertisements ”;

java.util.zip – ZipFile

java.util.zip – ZipFile Class ”; Previous Next Introduction The java.util.zip.ZipFile class is used to read entries from a zip file. Class Declaration Following is the declaration for java.util.zip.ZipFile class − public class ZipFile extends Object implements Closeable Fields Following are the fields for java.util.zip.ZipFile class − static int CENATT static int CENATX static int CENCOM static int CENCRC static int CENDSK static int CENEXT static int CENFLG static int CENHDR static int CENHOW static int CENLEN static int CENNAM static int CENOFF static long CENSIG static int CENSIZ static int CENTIM static int CENVEM static int CENVER static int ENDCOM static int ENDHDR static int ENDOFF static long ENDSIG static int ENDSIZ static int ENDSUB static int ENDTOT static int EXTCRC static int EXTHDR static int EXTLEN static long EXTSIG static int EXTSIZ static int LOCCRC static int LOCEXT static int LOCFLG static int LOCHDR static int LOCHOW static int LOCLEN static int LOCNAM static long LOCSIG static int LOCSIZ static int LOCTIM static int LOCVER static int OPEN_DELETE − Mode flag to open a zip file and mark it for deletion. static int OPEN_READ − Mode flag to open a zip file for reading. Constructors Sr.No. Constructor & Description 1 ZipFile(File file) Opens a ZIP file for reading given the specified File object. 2 ZipFile(File file, Charset charset) Opens a ZIP file for reading given the specified File object. 3 ZipFile(File file, int mode) Opens a new ZipFile to read from the specified File object in the specified mode. 4 ZipFile(File file, int mode, Charset charset) Opens a new ZipFile to read from the specified File object in the specified mode. 5 ZipFile(String name) Opens a zip file for reading. 6 ZipFile(String name, Charset charset) Opens a zip file for reading. Class Methods Sr.No. Method & Description 1 void close() Closes the ZIP file. 2 Enumeration<? extends ZipEntry> entries() Returns an enumeration of the ZIP file entries. 3 String getComment() Returns the zip file comment, or null if none. 4 ZipEntry getEntry(String name) Returns the zip file entry for the specified name, or null if not found. 5 InputStream getInputStream(ZipEntry entry) Returns an input stream for reading the contents of the specified zip file entry. 6 String getName() Returns the path name of the ZIP file. 7 int size() Returns the number of entries in the ZIP file. Methods Inherited This class inherits methods from the following classes − Java.lang.Object Print Page Previous Next Advertisements ”;