java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.util.zip.InflaterInputStream
net.i2p.util.ResettableGZIPInputStream
net.i2p.util.ReusableGZIPInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
Provide a cache of reusable GZIP unzipper streams. This provides stream output only, and therefore can handle unlimited size.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final LinkedBlockingQueue<ReusableGZIPInputStream> Streams ready for reuse.private static final booleanFalse on Apache Harmony 5.0M13 and on Android, where the deflater does not work after reset().Fields inherited from class InflaterInputStream
buf, inf, lenFields inherited from class FilterInputStream
inConstructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionstatic ReusableGZIPInputStreamacquire()Pull a cached instance.static voidClear the cache.static voidrelease(ReusableGZIPInputStream released) Release an instance back into the cache (this will reset the state).Methods inherited from class ResettableGZIPInputStream
close, destroy, getFinished, getRemaining, getTotalExpanded, getTotalRead, initialize, read, read, read, toStringModifier and TypeMethodDescriptionvoidclose()Does NOT call super.close(), as it cannot be reused if we do that.voiddestroy()Calls super.ResettableGZIPInputStream.close().booleanMoved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream.longMoved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream.longMoved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream.longMoved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream.final voidinitialize(InputStream compressedStream) Blocking call to initialize this stream with the data from the given compressed stream.intread()intread(byte[] buf) intread(byte[] buf, int off, int len) Read up to len bytes of uncompressed data into the given buffer.toString()Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream.Methods inherited from class InflaterInputStream
available, fill, mark, markSupported, reset, skipMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
Field Details
ENABLE_CACHING
private static final boolean ENABLE_CACHINGFalse on Apache Harmony 5.0M13 and on Android, where the deflater does not work after reset()._available
Streams ready for reuse.
Constructor Details
ReusableGZIPInputStream
private ReusableGZIPInputStream()Makes a stream with an empty buffer.
Method Details
acquire
Pull a cached instance.- Returns:
- a pooled instance if one is free, otherwise a newly constructed one
release
Release an instance back into the cache (this will reset the state).- Parameters:
released- the instance being handed back; destroyed instead when the pool is full or caching is disabled
clearCache
public static void clearCache()Clear the cache.