| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
net.rim.device.api.compress.GZIPOutputStream
public class GZIPOutputStream
Output stream for writing a data stream compressed with the GZIP algorithm (RFC 1952).
 
 
 Sample code
 
 public static byte[] compress( byte[] data )
 {    
     try 
     {
        
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
        
 GZIPOutputStream gzipStream = new GZIPOutputStream( baos, 6,
 GZIPOutputStream.MAX_LOG2_WINDOW_LENGTH );
        
 gzipStream.write( data );
        
 gzipStream.close();
     }
     catch(IOException ioe)
     {
        
 return null;
     }
 
     return baos.toByteArray();
 }
 
| 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 | 
|---|
public static final int MIN_LOG2_WINDOW_LENGTH
public static final int MAX_LOG2_WINDOW_LENGTH
public static final int COMPRESSION_NONE
public static final int COMPRESSION_BEST
| Constructor Detail | 
|---|
public GZIPOutputStream(OutputStream outputStream)
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.
outputStream - Underlying output stream to use.
public GZIPOutputStream(OutputStream outputStream,
                        int compressionValue)
outputStream - Underlying output stream to use.compressionValue - 0 to 9 representing compression value; 0 being none; 9 being best.
public GZIPOutputStream(OutputStream outputStream,
                        int compressionValue,
                        int windowLength)
 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.
 
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.| Method Detail | 
|---|
public void write(int data)
           throws IOException
write in class OutputStreamdata - the byte to be written
 
IOException - If an I/O error occurs.
public void write(byte[] data,
                  int dataOffset,
                  int dataLength)
           throws IOException
Invoke this method to compress, and then write, some bytes contained in the input array to this stream.
write in class OutputStreamdata - Data to write.dataOffset - First byte from provided array to compress and write.dataLength - Number of bytes from provided array to compress and write.
IOException - If an I/O error occurs.
public void flush()
           throws IOException
flush in class OutputStreamIOException - If an I/O error occurs.
public void close()
           throws IOException
close in class OutputStreamIOException - If an I/O error occurs.| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2011 Research In Motion Limited.  295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8.  All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal