public class DeflaterOutputStream extends FilterOutputStream
Deflater
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf
Output buffer for writing compressed data.
|
protected Deflater |
def
Compressor for this stream.
|
out| Constructor and Description |
|---|
DeflaterOutputStream(OutputStream
Creates a new output stream with a default compressor and buffer size.
|
DeflaterOutputStream(OutputStream
Creates a new output stream with a default compressor, a default buffer size and the specified flush mode.
|
DeflaterOutputStream(OutputStream
Creates a new output stream with the specified compressor and a default buffer size.
|
DeflaterOutputStream(OutputStream
Creates a new output stream with the specified compressor, flush mode and a default buffer size.
|
DeflaterOutputStream(OutputStream
Creates a new output stream with the specified compressor and buffer size.
|
DeflaterOutputStream(OutputStream
Creates a new output stream with the specified compressor, buffer size and flush mode.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Writes remaining compressed data to the output stream and closes the underlying stream.
|
protected void |
deflate()
Writes next block of compressed data to the output stream.
|
void |
finish()
Finishes writing compressed data to the output stream without closing the underlying stream.
|
void |
flush()
Flushes the compressed output stream.
|
void |
write(byte[] b, int off, int len)
Writes an array of bytes to the compressed output stream.
|
void |
write(int b)
Writes a byte to the compressed output stream.
|
writeprotected Deflaterdef
protected byte[] buf
public DeflaterOutputStream(OutputStreamout, Deflater def, int size, boolean syncFlush)
out - the output stream
def - the compressor ("deflater")
size - the output buffer size
syncFlush - if
true the
flush() method of this instance flushes the compressor with flush mode
Deflater.SYNC_FLUSH before flushing the output stream, otherwise only flushes the output stream
IllegalArgumentException - if
size <= 0
public DeflaterOutputStream(OutputStreamout, Deflater def, int size)
The new output stream instance is created as if by invoking the 4-argument constructor DeflaterOutputStream(out, def, size, false).
out - the output stream
def - the compressor ("deflater")
size - the output buffer size
IllegalArgumentException - if
size <= 0
public DeflaterOutputStream(OutputStreamout, Deflater def, boolean syncFlush)
out - the output stream
def - the compressor ("deflater")
syncFlush - if
true the
flush() method of this instance flushes the compressor with flush mode
Deflater.SYNC_FLUSH before flushing the output stream, otherwise only flushes the output stream
public DeflaterOutputStream(OutputStreamout, Deflater def)
The new output stream instance is created as if by invoking the 3-argument constructor DeflaterOutputStream(out, def, false).
out - the output stream
def - the compressor ("deflater")
public DeflaterOutputStream(OutputStreamout, boolean syncFlush)
out - the output stream
syncFlush - if
true the
flush() method of this instance flushes the compressor with flush mode
Deflater.SYNC_FLUSH before flushing the output stream, otherwise only flushes the output stream
public DeflaterOutputStream(OutputStreamout)
The new output stream instance is created as if by invoking the 2-argument constructor DeflaterOutputStream(out, false).
out - the output stream
public void write(int b)
throws IOException
write in class
FilterOutputStream
b - the byte to be written
IOException - if an I/O error has occurred
public void write(byte[] b,
int off,
int len)
throws IOException
write in class
FilterOutputStream
b - the data to be written
off - the start offset of the data
len - the length of the data
IOException - if an I/O error has occurred
FilterOutputStream.write(int)
public void finish()
throws IOException
IOException - if an I/O error has occurred
public void close()
throws IOException
close in interface
Closeable
close in interface
AutoCloseable
close in class
FilterOutputStream
IOException - if an I/O error has occurred
FilterOutputStream.flush() ,
FilterOutputStream.out
protected void deflate()
throws IOException
IOException - if an I/O error has occurred
public void flush()
throws IOException
syncFlush is
true when this compressed output stream is constructed, this method first flushes the underlying
compressor with the flush mode
Deflater.SYNC_FLUSH to force all pending data to be flushed out to the output stream and then flushes the output stream. Otherwise this method only flushes the output stream without flushing the
compressor.
flush in interface
Flushable
flush in class
FilterOutputStream
IOException - if an I/O error has occurred
FilterOutputStream.out