org.freehep.util.io
Class CompressableOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by org.freehep.util.io.CompressableOutputStream
All Implemented Interfaces:
Closeable, Flushable, FinishableOutputStream
Direct Known Subclasses:
BitOutputStream

public class CompressableOutputStream
extends FilterOutputStream
implements FinishableOutputStream

Special stream that can be used to write a header in uncompressed format, and the rest of the stream in compressed format. This stream is used by SWF, to compress the tail of the stream.

Version:
$Id: CompressableOutputStream.java 8584 2006-08-10 23:06:37Z duns $
Author:
Mark Donszelmann

Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
CompressableOutputStream(OutputStream out)
          Creates a Compressable Output Stream from given stream.
 
Method Summary
 void close()
           
 void finish()
          Finishes the current outputstream (compresses, flushes, caluclates CRC) and writes whatever is left in the buffers, but does not close the stream.
 void startCompressing()
          Start compressing from the next byte onwards.
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.FilterOutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompressableOutputStream

public CompressableOutputStream(OutputStream out)
Creates a Compressable Output Stream from given stream. Initially the stream does not compress.

Parameters:
out - stream to write to
Method Detail

write

public void write(int b)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException

finish

public void finish()
            throws IOException
Description copied from interface: FinishableOutputStream
Finishes the current outputstream (compresses, flushes, caluclates CRC) and writes whatever is left in the buffers, but does not close the stream.

Specified by:
finish in interface FinishableOutputStream
Throws:
IOException - if write fails

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class FilterOutputStream
Throws:
IOException

startCompressing

public void startCompressing()
                      throws IOException
Start compressing from the next byte onwards. Flushes what is currently in the buffer to the underlying stream and start compression from here.

Throws:
IOException - if write fails


Copyright © 2000-2007 FreeHEP. All Rights Reserved.