com.caucho.quercus.lib.zlib
Class ZlibOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.caucho.quercus.lib.file.AbstractBinaryOutput
          extended by com.caucho.quercus.lib.zlib.ZlibOutputStream
All Implemented Interfaces:
BinaryOutput, BinaryStream, java.io.Closeable, java.io.Flushable

public class ZlibOutputStream
extends AbstractBinaryOutput

As opposed to java's GZIPOutputStream, this class allows for more control on what is written to the underlying OutputStream.

See Also:
GZIPOutputStream

Field Summary
 
Fields inherited from interface com.caucho.quercus.lib.file.BinaryStream
SEEK_CUR, SEEK_END, SEEK_SET
 
Constructor Summary
ZlibOutputStream(java.io.OutputStream os)
           
ZlibOutputStream(java.io.OutputStream os, int compressionLevel, int strategy)
           
ZlibOutputStream(java.io.OutputStream os, int compressionLevel, int strategy, int encodingMode)
           
 
Method Summary
 void close()
          Closes the stream.
 void closeWrite()
          Closes the file.
 void flush()
          Flushes the output.
 long getPosition()
          Tells the position in the gzip stream
 boolean isEOF()
          Returns false always for a write stream.
 boolean setPosition(long offset)
          Sets the position.
 java.lang.String toString()
           
 void write(byte[] buffer, int offset, int length)
          Writes a buffer.
 void write(int v)
          Writes a byte.
 
Methods inherited from class com.caucho.quercus.lib.file.AbstractBinaryOutput
getOutputStream, getResourceType, print, print, seek, stat, write
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZlibOutputStream

public ZlibOutputStream(java.io.OutputStream os,
                        int compressionLevel,
                        int strategy,
                        int encodingMode)
                 throws java.io.IOException
Parameters:
out -
compressionLevel -
strategy - Deflate compression strategy
encodingMode - FORCE_GZIP to write gzwrite compatible output; FORCE_DEFLATE to write gzip header and zlib header, but do not write crc32 trailer
Throws:
java.io.IOException

ZlibOutputStream

public ZlibOutputStream(java.io.OutputStream os,
                        int compressionLevel,
                        int strategy)
                 throws java.io.IOException
Parameters:
os -
compressionLevel -
strategy - Deflate compression strategy
Throws:
java.io.IOException

ZlibOutputStream

public ZlibOutputStream(java.io.OutputStream os)
                 throws java.io.IOException
Throws:
java.io.IOException
Method Detail

write

public void write(int v)
           throws java.io.IOException
Writes a byte.

Specified by:
write in class java.io.OutputStream
Parameters:
input -
Throws:
java.io.IOException

write

public void write(byte[] buffer,
                  int offset,
                  int length)
           throws java.io.IOException
Description copied from interface: BinaryOutput
Writes a buffer.

Specified by:
write in interface BinaryOutput
Overrides:
write in class java.io.OutputStream
Parameters:
input -
offset -
length -
Throws:
java.io.IOException

flush

public void flush()
Description copied from class: AbstractBinaryOutput
Flushes the output.

Specified by:
flush in interface BinaryOutput
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class AbstractBinaryOutput

closeWrite

public void closeWrite()
Description copied from class: AbstractBinaryOutput
Closes the file.

Specified by:
closeWrite in interface BinaryOutput
Overrides:
closeWrite in class AbstractBinaryOutput

close

public void close()
Description copied from class: AbstractBinaryOutput
Closes the stream.

Specified by:
close in interface BinaryOutput
Specified by:
close in interface BinaryStream
Specified by:
close in interface java.io.Closeable
Overrides:
close in class AbstractBinaryOutput

isEOF

public boolean isEOF()
Returns false always for a write stream.

Specified by:
isEOF in interface BinaryStream
Overrides:
isEOF in class AbstractBinaryOutput

getPosition

public long getPosition()
Tells the position in the gzip stream

Specified by:
getPosition in interface BinaryStream
Overrides:
getPosition in class AbstractBinaryOutput

setPosition

public boolean setPosition(long offset)
Sets the position.

Specified by:
setPosition in interface BinaryStream
Overrides:
setPosition in class AbstractBinaryOutput

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object