public abstract class CompressedStream extends Stream
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
compressedStream |
static int |
DEFLATE
Used to create a stream that will be used for data compression.
|
static int |
INFLATE
Used to create a stream that will be used for data decompression.
|
protected int |
mode |
skipBuffer
Modifier | Constructor and Description |
---|---|
protected |
CompressedStream() |
protected |
CompressedStream(Stream stream,
int mode)
Creates a CompressedStream object that may be used to read compressed data from the given stream, or to write
compressed data to the given stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this stream WITHOUT closing the underlying stream, which must be explicitly closed by the user.
|
protected abstract java.lang.Object |
createDeflate(Stream stream) |
protected abstract java.lang.Object |
createInflate(Stream stream) |
protected void |
finalize() |
int |
readBytes(byte[] buf,
int start,
int count)
Attempts to read count bytes to the given byte array, starting from offset start.
This method can be used only with CompressedStreams created in INFLATE mode, and should be used only for reading compressed data from the original stream, returning uncompressed data on the give byte array. |
int |
writeBytes(byte[] buf,
int start,
int count)
Attempts to write count bytes from the given byte array, starting from offset start.
This method can be used only with CompressedStreams created in DEFLATE mode, and should be used only for compressing the contents of the given byte array, and writing the compressed data to the original stream. |
asInputStream, asOutputStream, asStream, asStream, skipBytes, wrapInputStream, wrapInputStreamToStream, write, writeBytes, writeBytes, writeBytes
protected java.lang.Object compressedStream
protected int mode
public static final int DEFLATE
public static final int INFLATE
protected CompressedStream()
protected CompressedStream(Stream stream, int mode)
stream
- input stream.mode
- its value must be either DEFLATE or INFLATE.protected abstract java.lang.Object createDeflate(Stream stream)
protected abstract java.lang.Object createInflate(Stream stream)
public int readBytes(byte[] buf, int start, int count) throws IOException, ZipException
readBytes
in class Stream
buf
- the byte array to read data intostart
- the start position in the arraycount
- the number of bytes to readIOException
ZipException
public int writeBytes(byte[] buf, int start, int count) throws IOException
writeBytes
in class Stream
buf
- the byte array to write data fromstart
- the start position in the byte arraycount
- the number of bytes to writeIOException
public void close() throws IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
IOException
- If an I/O error occurs.protected void finalize()
finalize
in class java.lang.Object