net.rim.device.api.compress
Class GZIPOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--net.rim.device.api.compress.GZIPOutputStream

public class GZIPOutputStream
extends OutputStream

Output stream for writing a data stream compressed with the GZIP algorithm (RFC 1952).


Field Summary
static int COMPRESSION_BEST
           
static int COMPRESSION_NONE
           
static int MAX_LOG2_WINDOW_LENGTH
           
static int MIN_LOG2_WINDOW_LENGTH
           
 
Constructor Summary
GZIPOutputStream(OutputStream outputStream)
          Creates a new GZIPOutputStream instance with COMPRESSION_NONE.
GZIPOutputStream(OutputStream outputStream, int compressionValue)
          Creates a new GZIPOutputStream instance.
GZIPOutputStream(OutputStream outputStream, int compressionValue, int windowLength)
          Creates a new GZIPOutputStream instance.
 
Method Summary
 void close()
          Closes this output stream.
 void flush()
          Flushes this stream, writing out any remaining buffered data.
 void write(byte[] data, int dataOffset, int dataLength)
          Writes some bytes from byte array to this stream.
 void write(int data)
          Writes a byte to this stream.
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPRESSION_BEST

public static final int COMPRESSION_BEST
Since:
JDE 4.1.0

COMPRESSION_NONE

public static final int COMPRESSION_NONE
Since:
JDE 4.1.0

MAX_LOG2_WINDOW_LENGTH

public static final int MAX_LOG2_WINDOW_LENGTH
Since:
JDE 4.1.0

MIN_LOG2_WINDOW_LENGTH

public static final int MIN_LOG2_WINDOW_LENGTH
Since:
JDE 4.1.0
Constructor Detail

GZIPOutputStream

public GZIPOutputStream(OutputStream outputStream)
Creates a new GZIPOutputStream instance with COMPRESSION_NONE.

Note this constructor provides no compression; this is done to be compatible with prior implementations of this class. Use the alternate constructor which accepts the compression value to achieve compression.

Parameters:
outputStream - Underlying output stream to use.

GZIPOutputStream

public GZIPOutputStream(OutputStream outputStream,
                        int compressionValue)
Creates a new GZIPOutputStream instance.

Parameters:
outputStream - Underlying output stream to use.
compressionValue - 0 to 9 representing compression value; 0 being none; 9 being best.
Since:
JDE 4.1.0

GZIPOutputStream

public GZIPOutputStream(OutputStream outputStream,
                        int compressionValue,
                        int windowLength)
Creates a new GZIPOutputStream instance.

windowLength can range from 8 to 15. Note: if the value was 10, the window length would be 2^10 = 1024 bytes. This parameter can be used to limit the window length for those decompressors which are not capable of dealing with the maximum window length (2^15 -> 32KB). Note, the actual window length may be smaller.

Parameters:
outputStream - Underlying output stream to use.
compressionValue - 0 to 9 representing compression value; 0 being none; 9 being best.
windowLength - The window length to use.
Since:
JDE 4.1.0
Method Detail

close

public void close()
           throws IOException
Closes this output stream.

Overrides:
close in class OutputStream
Throws:
IOException - If an I/O error occurs.

flush

public void flush()
           throws IOException
Flushes this stream, writing out any remaining buffered data.

Overrides:
flush in class OutputStream
Throws:
IOException - If an I/O error occurs.

write

public void write(byte[] data,
                  int dataOffset,
                  int dataLength)
           throws IOException
Writes some bytes from byte array to this stream.

Invoke this method to compress, and then write, some bytes contained in the input array to this stream.

Overrides:
write in class OutputStream
Parameters:
data - Data to write.
dataOffset - First byte from provided array to compress and write.
dataLength - Number of bytes from provided array to compress and write.
Throws:
IOException - If an I/O error occurs.

write

public void write(int data)
           throws IOException
Writes a byte to this stream.

Overrides:
write in class OutputStream
Parameters:
data - the byte to be written

Throws:
IOException - If an I/O error occurs.



Copyright 1999-2008 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.