Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.emory.mathcs.util.io
Class CompressedOutputStream

    java.lang.Object
      java.io.OutputStream
          java.io.FilterOutputStream
              edu.emory.mathcs.util.io.CompressedOutputStream

public class CompressedOutputStream
extends java.io.FilterOutputStream

Filter output stream that compresses data and features strong flush semantics. Data is written as gzipped packets of variable size. Flushing causes immediate ending of currently written packet and sending all the data off. Therefore, this stream can be used as a transport for RMI or RPC. Note that standard `ZipOutputStream` and `GZIPOutputStream` are useless for this purpose due to their insufficiently strong flushing semantics: they don't guarantee that flush sends out all the data that was written so far, which leads to deadlocks in request-response-based protocols.

Compression ratio decreases with decreasing packet size. Hence, the gain will be low or none in RMI applications that exchange small chunks of data. Since the protocol adds two bytes of metadata per each packet, in the extreme case (flushing every single byte) the number of bytes actually sent is tripled. On the other hand, the compression ratio may be significant if large chunks are exchanged, e.g. if large arrays are sent as parameters or received as return values.

Version:
  1.0
Author:
  Dawid Kurzyniec
See Also:
  `CompressedInputStream`

Field Summary

Fields inherited from class java.io.FilterOutputStream
`out`

Constructor Summary
`CompressedOutputStream(java.io.OutputStream out)`
`CompressedOutputStream(java.io.OutputStream out, int bufSize)`

Method Summary
`void` | `flush()`
`void` | `write(byte[] data, int off, int len)`
`void` | `write(int b)`

Methods inherited from class java.io.FilterOutputStream
`close, write`

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

Constructor Detail

### CompressedOutputStream

    public CompressedOutputStream(java.io.OutputStream out)

### CompressedOutputStream

    public CompressedOutputStream(java.io.OutputStream out,
                                  int bufSize)

Method Detail

### write

    public void write(int b)
               throws java.io.IOException

  Throws:
    `java.io.IOException`

### write

    public void write(byte[] data,
                      int off,
                      int len)
               throws java.io.IOException

  Throws:
    `java.io.IOException`

### flush

    public void flush()
               throws java.io.IOException

  Throws:
    `java.io.IOException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD