Known Direct Subclasses
GZIPOutputStream |
The GZIPOutputStream class is used to write data to a stream in the
GZIP storage format. |
ZipOutputStream |
Used to write (compress) data into zip files. |
|
Known Indirect Subclasses
JarOutputStream |
The JarOutputStream is used to write data in the JarFile
format to an arbitrary output stream
|
|
Class Overview
This class provides an implementation of FilterOutputStream
that
compresses data using the DEFLATE algorithm. Basically it wraps the
Deflater
class and takes care of the buffering.
Summary
Fields |
protected
byte[] |
buf |
The buffer for the data to be written to. |
protected
Deflater |
def |
The deflater used. |
Public Constructors |
|
DeflaterOutputStream(OutputStream os)
Constructs a new instance with a default-constructed Deflater .
|
|
DeflaterOutputStream(OutputStream os, Deflater def)
Constructs a new instance with the given Deflater .
|
|
DeflaterOutputStream(OutputStream os, Deflater def, int bufferSize)
Constructs a new instance with the given Deflater and buffer size.
|
|
DeflaterOutputStream(OutputStream os, boolean syncFlush)
Constructs a new instance with the given flushing behavior (see flush() ).
|
|
DeflaterOutputStream(OutputStream os, Deflater def, boolean syncFlush)
Constructs a new instance with the given Deflater and
flushing behavior (see flush() ).
|
|
DeflaterOutputStream(OutputStream os, Deflater def, int bufferSize, boolean syncFlush)
Constructs a new instance with the given Deflater , buffer size, and
flushing behavior (see flush() ).
|
Public Methods |
void
|
close()
Writes any unwritten compressed data to the underlying stream, the closes
all underlying streams.
|
void
|
finish()
Writes any unwritten data to the underlying stream.
|
void
|
flush()
Flushes the underlying stream.
|
void
|
write(byte[] buffer, int offset, int byteCount)
Compresses byteCount bytes of data from buf starting at
offset and writes it to the underlying stream.
|
void
|
write(int i)
Writes one byte to the target stream.
|
Protected Methods |
void
|
deflate()
Compress the data in the input buffer and write it to the underlying
stream.
|
[Expand]
Inherited Methods |
From class
java.io.FilterOutputStream
void
|
close()
Closes this stream.
|
void
|
flush()
Ensures that all pending data is sent out to the target stream.
|
void
|
write(byte[] buffer, int offset, int length)
Writes count bytes from the byte array buffer starting at
offset to the target stream.
|
void
|
write(int oneByte)
Writes one byte to the target stream.
|
|
From class
java.io.OutputStream
void
|
close()
Closes this stream.
|
void
|
flush()
Flushes this stream.
|
void
|
write(byte[] buffer, int offset, int count)
Writes count bytes from the byte array buffer starting at
position offset to this stream.
|
void
|
write(byte[] buffer)
Equivalent to write(buffer, 0, buffer.length) .
|
abstract
void
|
write(int oneByte)
Writes a single byte to this stream.
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
|
From interface
java.io.Closeable
abstract
void
|
close()
Closes the object and release any system resources it holds.
|
|
From interface
java.io.Flushable
abstract
void
|
flush()
Flushes the object by writing out any buffered data to the underlying
output.
|
|
From interface
java.lang.AutoCloseable
abstract
void
|
close()
Closes the object and release any system resources it holds.
|
|
Fields
protected
byte[]
buf
The buffer for the data to be written to.
Public Constructors
public
DeflaterOutputStream
(OutputStream os)
Constructs a new instance with a default-constructed Deflater
.
Constructs a new instance with the given Deflater
.
public
DeflaterOutputStream
(OutputStream os, Deflater def, int bufferSize)
Constructs a new instance with the given Deflater
and buffer size.
public
DeflaterOutputStream
(OutputStream os, boolean syncFlush)
Constructs a new instance with the given flushing behavior (see flush()
).
public
DeflaterOutputStream
(OutputStream os, Deflater def, boolean syncFlush)
Constructs a new instance with the given Deflater
and
flushing behavior (see flush()
).
public
DeflaterOutputStream
(OutputStream os, Deflater def, int bufferSize, boolean syncFlush)
Constructs a new instance with the given Deflater
, buffer size, and
flushing behavior (see flush()
).
Public Methods
public
void
close
()
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.
Throws
IOException
| If an error occurs while closing the data compression
process.
|
public
void
finish
()
Writes any unwritten data to the underlying stream. Does not close the
stream.
public
void
flush
()
Flushes the underlying stream. This flushes only the bytes that can be
compressed at the highest level.
For deflater output streams constructed with the syncFlush
parameter set to true,
this first flushes all outstanding data so that it may be immediately read by its recipient.
Doing so may degrade compression but improve interactive behavior.
public
void
write
(byte[] buffer, int offset, int byteCount)
Compresses byteCount
bytes of data from buf
starting at
offset
and writes it to the underlying stream.
Parameters
buffer
| the buffer to write. |
offset
| the index of the first byte in buffer to write. |
byteCount
| the number of bytes in buffer to write. |
public
void
write
(int i)
Writes one byte to the target stream. Only the low order byte of the
integer oneByte
is written.
Parameters
i
| the byte to be written. |
Protected Methods
protected
void
deflate
()
Compress the data in the input buffer and write it to the underlying
stream.