Package com.ning.compress.gzip
Class OptimizedGZIPOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- com.ning.compress.gzip.OptimizedGZIPOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class OptimizedGZIPOutputStream extends java.io.OutputStream
Optimized variant ofGZIPOutputStream
that reuses underlyingDeflater
instance}.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.zip.CRC32
_crc
protected java.util.zip.Deflater
_deflater
protected java.util.zip.DeflaterOutputStream
_deflaterOut
protected byte[]
_eightByteBuffer
protected GZIPRecycler
_gzipRecycler
protected java.io.OutputStream
_rawOut
Underlying output stream that header, compressed content and footer go to(package private) static byte[]
DEFAULT_HEADER
For now, static header seems fine, since JDK default gzip writer does it too:private static int
GZIP_MAGIC
GZIP header magic number; written out LSB like most everything else (i.e.
-
Constructor Summary
Constructors Constructor Description OptimizedGZIPOutputStream(java.io.OutputStream out)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
_putInt(byte[] buf, int offset, int value)
Stupid GZIP, writes stuff in wrong order (not network, but x86)private void
_writeTrailer(java.io.OutputStream out)
void
close()
void
flush()
void
write(byte[] buf)
void
write(byte[] buf, int off, int len)
void
write(int c)
-
-
-
Field Detail
-
GZIP_MAGIC
private static final int GZIP_MAGIC
GZIP header magic number; written out LSB like most everything else (i.e. as 0x1f 0x8b)- See Also:
- Constant Field Values
-
DEFAULT_HEADER
static final byte[] DEFAULT_HEADER
For now, static header seems fine, since JDK default gzip writer does it too:
-
_deflater
protected java.util.zip.Deflater _deflater
-
_gzipRecycler
protected final GZIPRecycler _gzipRecycler
-
_eightByteBuffer
protected final byte[] _eightByteBuffer
-
_rawOut
protected java.io.OutputStream _rawOut
Underlying output stream that header, compressed content and footer go to
-
_deflaterOut
protected java.util.zip.DeflaterOutputStream _deflaterOut
-
_crc
protected java.util.zip.CRC32 _crc
-
-
Method Detail
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public final void write(byte[] buf) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public final void write(int c) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] buf, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
_writeTrailer
private void _writeTrailer(java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
_putInt
private static final void _putInt(byte[] buf, int offset, int value)
Stupid GZIP, writes stuff in wrong order (not network, but x86)
-
-