net.i2p.util
Class ResettableGZIPInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.util.zip.InflaterInputStream
              extended by net.i2p.util.ResettableGZIPInputStream
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
ReusableGZIPInputStream

public class ResettableGZIPInputStream
extends InflaterInputStream

GZIP implementation per RFC 1952, reusing java's standard CRC32 and Inflater and InflaterInputStream implementations. The main difference is that this implementation allows its state to be reset to initial values, and hence reused, while the standard GZIPInputStream reads the GZIP header from the stream on instantiation.


Field Summary
 
Fields inherited from class java.util.zip.InflaterInputStream
buf, inf, len
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
ResettableGZIPInputStream()
          Build a new GZIP stream without a bound compressed stream.
ResettableGZIPInputStream(InputStream compressedStream)
          Warning - blocking!
 
Method Summary
 void close()
          Does NOT call super.close(), as it cannot be reused if we do that.
 boolean getFinished()
          Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream
 long getRemaining()
          Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream
 long getTotalExpanded()
          Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream
 long getTotalRead()
          Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream
 void initialize(InputStream compressedStream)
          Blocking call to initialize this stream with the data from the given compressed stream.
 int read()
           
 int read(byte[] buf)
           
 int read(byte[] buf, int off, int len)
           
 String toString()
          Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream
 
Methods inherited from class java.util.zip.InflaterInputStream
available, fill, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResettableGZIPInputStream

public ResettableGZIPInputStream()
Build a new GZIP stream without a bound compressed stream. You need to initialize this with initialize(compressedStream) when you want to decompress a stream.


ResettableGZIPInputStream

public ResettableGZIPInputStream(InputStream compressedStream)
                          throws IOException
Warning - blocking!

Throws:
IOException
Method Detail

initialize

public void initialize(InputStream compressedStream)
                throws IOException
Blocking call to initialize this stream with the data from the given compressed stream.

Throws:
IOException

read

public int read()
         throws IOException
Overrides:
read in class InflaterInputStream
Throws:
IOException

read

public int read(byte[] buf)
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] buf,
                int off,
                int len)
         throws IOException
Overrides:
read in class InflaterInputStream
Throws:
IOException

getTotalRead

public long getTotalRead()
Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream

Since:
0.8.9

getTotalExpanded

public long getTotalExpanded()
Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream

Since:
0.8.9

getRemaining

public long getRemaining()
Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream

Since:
0.8.9

getFinished

public boolean getFinished()
Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream

Since:
0.8.9

close

public void close()
           throws IOException
Does NOT call super.close(), as it cannot be reused if we do that. Broken before 0.9.20.

Specified by:
close in interface Closeable
Overrides:
close in class InflaterInputStream
Throws:
IOException
Since:
0.9.20

toString

public String toString()
Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream

Overrides:
toString in class Object
Since:
0.8.9