## org.apache.hadoop.io.compress
Class CompressorStream

    java.lang.Object
      java.io.OutputStream
          org.apache.hadoop.io.compress.CompressionOutputStream
              org.apache.hadoop.io.compress.CompressorStream

All Implemented Interfaces:
  Closeable, Flushable

Direct Known Subclasses:
  BlockCompressorStream, GzipCodec.GzipOutputStream

    public class CompressorStream

extends CompressionOutputStream

Field Summary
`protected byte[]` `buffer`
`protected boolean` `closed`
`protected Compressor` `compressor`

Fields inherited from class org.apache.hadoop.io.compress.CompressionOutputStream
`out`

Constructor Summary
`protected` `CompressorStream(OutputStream out)` Allow derived classes to directly set the underlying stream.
`` `CompressorStream(OutputStream out, Compressor compressor)`
`` `CompressorStream(OutputStream out, Compressor compressor, int bufferSize)`

Method Summary
`void` `close()`
`protected void` `compress()`
`void` `finish()` Finishes writing compressed data to the output stream without closing the underlying stream.
`void` `resetState()` Reset the compression to the initial state.
`void` `write(byte[] b, int off, int len)` Write compressed bytes to the stream.
`void` `write(int b)`

Methods inherited from class org.apache.hadoop.io.compress.CompressionOutputStream
`flush`

Methods inherited from class java.io.OutputStream
`write`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### compressor

    protected Compressor compressor

### buffer

    protected byte[] buffer

### closed

    protected boolean closed

Constructor Detail

### CompressorStream

    public CompressorStream(OutputStream out,
                            Compressor compressor,
                            int bufferSize)

### CompressorStream

    public CompressorStream(OutputStream out,
                            Compressor compressor)

### CompressorStream

    protected CompressorStream(OutputStream out)

  Allow derived classes to directly set the underlying stream.

  Parameters:
    `out` - Underlying output stream.

Method Detail

### write

    public void write(byte[] b,
                      int off,
                      int len)
               throws IOException

  Description copied from class: `CompressionOutputStream`
  Write compressed bytes to the stream. Made abstract to prevent leakage to underlying stream.

  Specified by:
    `write` in class `CompressionOutputStream`
  Throws:
    `IOException`

### compress

    protected void compress()
                     throws IOException

  Throws:
    `IOException`

### finish

    public void finish()
                throws IOException

  Description copied from class: `CompressionOutputStream`
  Finishes writing compressed data to the output stream without closing the underlying stream.

  Specified by:
    `finish` in class `CompressionOutputStream`
  Throws:
    `IOException`

### resetState

    public void resetState()
                    throws IOException

  Description copied from class: `CompressionOutputStream`
  Reset the compression to the initial state. Does not reset the underlying stream.

  Specified by:
    `resetState` in class `CompressionOutputStream`
  Throws:
    `IOException`

### close

    public void close()
               throws IOException

  Specified by:
    `close` in interface `Closeable`
  Overrides:
    `close` in class `CompressionOutputStream`
  Throws:
    `IOException`

### write

    public void write(int b)
               throws IOException

  Specified by:
    `write` in class `OutputStream`
  Throws:
    `IOException`

Copyright © 2009 The Apache Software Foundation