|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream java.io.FilterInputStream tribble.io.DeflaterInputStream
public class DeflaterInputStream
Implements an input stream filter for compressing data in the "deflate" compression format.
This class serves as a complement to the standard java.util.zip.InflaterInputStream and java.util.zip.DeflaterOutputStream classes. It compresses ("deflates") data like the latter class, but reads the compressed data from an input stream like the former class.
Copyright ©2005 by David R. Tribble, all rights reserved.
Permission is granted to freely use and distribute this source
code provided that the original copyright and authorship notices
remain intact.
InflaterOutputStream
,
DeflaterOutputStream
,
InflaterInputStream
,
java.util.zip.DeflaterInputStream
Field Summary | |
---|---|
protected byte[] |
m_buf
Input buffer for reading compressed data. |
protected java.util.zip.Deflater |
m_defl
Compressor for this stream. |
protected long |
m_inBytes
Total bytes read from the underlying input stream. |
protected long |
m_outBytes
Total bytes returned from this input stream. |
(package private) static java.lang.String |
REV
Revision information. |
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
DeflaterInputStream(java.io.InputStream in)
Construct a new input stream with a default compressor and buffer size. |
|
DeflaterInputStream(java.io.InputStream in,
java.util.zip.Deflater defl)
Construct a new input stream with the specified compressor and a default buffer size. |
|
DeflaterInputStream(java.io.InputStream in,
java.util.zip.Deflater defl,
int bufLen)
Construct a new input stream with the specified compressor and buffer size. |
Method Summary | |
---|---|
int |
available()
Determine the number of bytes that can be read from this input stream without blocking. |
void |
close()
Close this input stream and its underlying input stream, discarding any pending uncompressed data. |
protected void |
finalize()
Finalization. |
long |
getTotalIn()
Determine the total number of bytes read from the underlying input stream. |
long |
getTotalOut()
Determine the total number of bytes read from this compressed input stream. |
static void |
main(java.lang.String[] args)
Uncompress a file containing data stored in the "deflate" compression format. |
void |
mark(int limit)
This operation is not supported. |
boolean |
markSupported()
Test if this input stream supports the mark() and
reset() methods. |
int |
read()
Read compressed data from the input stream. |
int |
read(byte[] buf)
Read compressed data from the input stream. |
int |
read(byte[] buf,
int off,
int len)
Read compressed data from the input stream. |
void |
reset()
This operation is not supported. |
long |
skip(long n)
Skip over and discard data from the input stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final java.lang.String REV
protected java.util.zip.Deflater m_defl
protected byte[] m_buf
protected long m_inBytes
protected long m_outBytes
Constructor Detail |
---|
public DeflaterInputStream(java.io.InputStream in)
in
- Input stream to read the uncompressed data to.public DeflaterInputStream(java.io.InputStream in, java.util.zip.Deflater defl)
in
- Input stream to read the uncompressed data to.defl
- Compressor ("deflater") for this stream.public DeflaterInputStream(java.io.InputStream in, java.util.zip.Deflater defl, int bufLen)
in
- Input stream to read the uncompressed data to.defl
- Compressor ("deflater") for this stream.bufLen
- Compression buffer size.
java.lang.NullPointerException
- (unchecked)
Thrown if in or defl is null.
java.lang.IllegalArgumentException
- (unchecked)
Thrown if bufLen is less than 1.Method Detail |
---|
public static void main(java.lang.String[] args) throws java.lang.Exception
The file to be uncompressed should contain compressed data stored in the
"deflate" compression format, such as the output from the
InflaterOutputStream
class.
Usage
java tribble.io.DeflaterInputStream [-option...] file
Options
args
- Command line arguments.
java.lang.Exception
InflaterOutputStream.main()
public void close() throws java.io.IOException
Note that this method can be called multiple times with no ill effects.
close
in interface java.io.Closeable
close
in class java.io.FilterInputStream
java.io.IOException
- Thrown if an I/O error occurs.public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
- Thrown if an I/O (read) error occurs.
java.lang.NullPointerException
- (unchecked)
Thrown if the underlying input stream is closed.public int read(byte[] buf) throws java.io.IOException
read
in class java.io.FilterInputStream
buf
- Buffer into which the data is read.
An attempt is made to fill the entire array.
java.io.IOException
- Thrown if an I/O (read) error occurs.
java.lang.NullPointerException
- (unchecked)
Thrown if the underlying input stream is closed.public int read(byte[] buf, int off, int len) throws java.io.IOException
read
in class java.io.FilterInputStream
buf
- Buffer into which the data is read.off
- Starting offset of the data within buf.len
- Maximum number of compressed bytes to read into buf.
java.io.IOException
- Thrown if an I/O (read) error occurs.
java.lang.NullPointerException
- (unchecked)
Thrown if the underlying input stream is closed.public long skip(long n) throws java.io.IOException
skip
in class java.io.FilterInputStream
n
- Number of bytes to be skipped.
java.io.IOException
- Thrown if an I/O (read) error occurs.
java.lang.NullPointerException
- (unchecked)
Thrown if the underlying input stream is closed.public int available() throws java.io.IOException
Programs should not count on this method to return the actual number of bytes that could be read without blocking.
available
in class java.io.FilterInputStream
java.io.IOException
- Thrown if an I/O (read) error occurs.public boolean markSupported()
mark()
and
reset()
methods.
These operations are not supported.
markSupported
in class java.io.FilterInputStream
public void mark(int limit)
mark
in class java.io.FilterInputStream
limit
- Maximum bytes that can be read before invalidating the position marker.public void reset() throws java.io.IOException
reset
in class java.io.FilterInputStream
java.io.IOException
- Always thrown.public long getTotalIn()
public long getTotalOut()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |