Build 1.0_r1(from source)

java.util.zip
Class DeflaterOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by java.util.zip.DeflaterOutputStream
All Implemented Interfaces:
Closeable, Flushable
Direct Known Subclasses:
GZIPOutputStream, ZipOutputStream

public class DeflaterOutputStream
extends FilterOutputStream

The DeflaterOutputStream class implements a stream filter for the writing of compressed data to a stream. Compression is performed by an instance of Deflater.


Field Summary
protected  byte[] buf
           
(package private) static int BUF_SIZE
           
protected  Deflater def
           
(package private)  boolean done
           
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
DeflaterOutputStream(OutputStream os)
          Constructs a new DeflaterOutputStream instance using os as the underlying stream.
DeflaterOutputStream(OutputStream os, Deflater def)
          Constructs a new DeflaterOutputStream instance using os as the underlying stream.
DeflaterOutputStream(OutputStream os, Deflater def, int bsize)
          Constructs a new DeflaterOutputStream instance using os as the underlying stream.
 
Method Summary
 void close()
          Writes any unwritten compressed data to the underlying stream, the closes all underlying streams.
protected  void deflate()
          Compress the data in the input buffer and write it to the underlying stream.
 void finish()
          Write any unwritten data to the underlying stream.
 void write(byte[] buffer, int off, int nbytes)
          Compress nbytes of data from buf starting at off and write it to the underlying stream.
 void write(int i)
          Writes the specified byte oneByte to this FilterOutputStream.
 
Methods inherited from class java.io.FilterOutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUF_SIZE

static final int BUF_SIZE
See Also:
Constant Field Values

buf

protected byte[] buf

def

protected Deflater def

done

boolean done
Constructor Detail

DeflaterOutputStream

public DeflaterOutputStream(OutputStream os,
                            Deflater def)
Constructs a new DeflaterOutputStream instance using os as the underlying stream. The provided Deflater instance will be used to compress data.

Parameters:
os - OutputStream to receive compressed data
def - Deflater to perform compression

DeflaterOutputStream

public DeflaterOutputStream(OutputStream os)
Constructs a new DeflaterOutputStream instance using os as the underlying stream.

Parameters:
os - OutputStream to receive compressed data

DeflaterOutputStream

public DeflaterOutputStream(OutputStream os,
                            Deflater def,
                            int bsize)
Constructs a new DeflaterOutputStream instance using os as the underlying stream. The provided Deflater instance will be used to compress data. The internal buffer for storing compressed data will be of size bsize.

Parameters:
os - OutputStream to receive compressed data
def - Deflater to perform compression
bsize - size of internal compression buffer
Method Detail

deflate

protected void deflate()
                throws IOException
Compress the data in the input buffer and write it to the underlying stream.

Throws:
IOException - If an error occurs during deflation.

close

public void close()
           throws IOException
Writes any unwritten compressed data to the underlying stream, the closes all underlying streams. This stream can no longer be used after close() has been called.

Specified by:
close in interface Closeable
Overrides:
close in class FilterOutputStream
Throws:
IOException - If an error occurs during close.

finish

public void finish()
            throws IOException
Write any unwritten data to the underlying stream. Do not close the stream. This allows subsequent Deflater's to write to the same stream. This Deflater cannot be used again.

Throws:
IOException - If an error occurs.

write

public void write(int i)
           throws IOException
Description copied from class: FilterOutputStream
Writes the specified byte oneByte to this FilterOutputStream. Only the low order byte of oneByte is written. This implementation writes the byte to the target OutputStream.

Overrides:
write in class FilterOutputStream
Parameters:
i - the byte to be written
Throws:
IOException - If an error occurs attempting to write to this FilterOutputStream.

write

public void write(byte[] buffer,
                  int off,
                  int nbytes)
           throws IOException
Compress nbytes of data from buf starting at off and write it to the underlying stream.

Overrides:
write in class FilterOutputStream
Parameters:
buffer - Buffer of data to compress
off - offset in buffer to extract data from
nbytes - Number of bytes of data to compress and write
Throws:
IOException - If an error occurs during writing.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature