org.hd.d.pg2k.svrCore
Class DefOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by java.util.zip.DeflaterOutputStream
              extended by org.hd.d.pg2k.svrCore.DefOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public final class DefOutputStream
extends java.util.zip.DeflaterOutputStream

Like GZIPOutputStream but no GZIP header or checksum. This is meant to give maximum compression and assumes error checking/recovery is done elsewhere.


Field Summary
 
Fields inherited from class java.util.zip.DeflaterOutputStream
buf, def
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
  DefOutputStream(java.io.OutputStream out)
          Creates a new output stream with a default buffer size.
private DefOutputStream(java.io.OutputStream out, int size)
          Creates a new output stream with the specified buffer size.
 
Method Summary
 void close()
          Writes remaining compressed data to the output stream and closes it.
 void finish()
          Finishes writing compressed data to the output stream without closing it.
 void write(byte[] buf, int off, int len)
          Writes array of bytes to the compressed output stream; blocking.
 
Methods inherited from class java.util.zip.DeflaterOutputStream
deflate, write
 
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

DefOutputStream

private DefOutputStream(java.io.OutputStream out,
                        int size)
Creates a new output stream with the specified buffer size. Forces use of the best possible compression at the possible expense of CPU time.

This compressed stream is wrapped with neither GZIP nor ZLIB headers/checksums to minimise overheads; we'd better be doing error detection and correction elsewhere!

Parameters:
out - the output stream
size - the output buffer size; changing this from the default of 512 bytes is unlikely to improve performance

DefOutputStream

public DefOutputStream(java.io.OutputStream out)
Creates a new output stream with a default buffer size.

Parameters:
out - the output stream
Method Detail

write

public void write(byte[] buf,
                  int off,
                  int len)
           throws java.io.IOException
Writes array of bytes to the compressed output stream; blocking.

Overrides:
write in class java.util.zip.DeflaterOutputStream
Throws:
java.io.IOException - if an I/O error has occurred

finish

public void finish()
            throws java.io.IOException
Finishes writing compressed data to the output stream without closing it.

Overrides:
finish in class java.util.zip.DeflaterOutputStream
Throws:
java.io.IOException - if an I/O error has occurred

close

public void close()
           throws java.io.IOException
Writes remaining compressed data to the output stream and closes it.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.util.zip.DeflaterOutputStream
Throws:
java.io.IOException - if an I/O error has occurred

DHD Multimedia Gallery V1.50.55

Copyright (c) 1996-2008, Damon Hart-Davis. All rights reserved.