|
|||||||||
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.ZLibOutputStream
public class ZLibOutputStream
Output stream for writing a data stream compressed with the ZLib algorithm (RFC 1950, RFC 1951).
Sample code
try
{
ByteArrayOutputStream bufferOut = new
ByteArrayOutputStream();
ZLibOutputStream compressedOut = new
ZLibOutputStream( bufferOut );
compressedOut.write( data, offset,
length );
compressedOut.close();
}
catch(IOException ioe)
{
}
Field Summary | ||
---|---|---|
static int |
COMPRESSION_BEST
|
|
static int |
COMPRESSION_NONE
|
|
static int |
MAX_LOG2_WINDOW_LENGTH
|
|
static int |
MIN_LOG2_WINDOW_LENGTH
|
Constructor Summary | ||
---|---|---|
ZLibOutputStream(OutputStream outputStream)
Creates a new ZLibOutputStream instance (the header and trailer wrapping will be generated, and the maximum window length may be used - see other constructors). |
||
ZLibOutputStream(OutputStream outputStream,
boolean noWrap)
Creates a new ZLibOutputStream instance (the maximum window length may be used - see other constructors). |
||
ZLibOutputStream(OutputStream outputStream,
boolean noWrap,
int maxLog2WindowLength)
Creates a new ZLibOutputStream instance. |
||
ZLibOutputStream(OutputStream outputStream,
boolean noWrap,
int maxLog2WindowLength,
int compressionValue)
Creates a new ZLibOutputStream 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 ZLibOutputStream(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 ZLibOutputStream(OutputStream outputStream, boolean noWrap)
If noWrap
is true
, the compressor will not generate
the ZLib 16 bit header and the 32 bit trailer checksum. This mode is necessary
for PKZip/Info-ZIP and GZIP compatibility.
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.noWrap
- If true, the header and trailer will not be generated.public ZLibOutputStream(OutputStream outputStream, boolean noWrap, int maxLog2WindowLength)
If noWrap
is true
, the compressor will not generate
the ZLib 16 bit header and the 32 bit trailer checksum. This mode is necessary
for PKZip/Info-ZIP and GZIP compatibility.
maxLog2WindowLength
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.
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.noWrap
- If true, the header and trailer will not be generated.maxLog2WindowLength
- maximum window length.public ZLibOutputStream(OutputStream outputStream, boolean noWrap, int maxLog2WindowLength, int compressionValue)
If noWrap
is true
, the compressor will not generate
the ZLib 16 bit header and the 32 bit trailer checksum. This mode is necessary
for PKZip/Info-ZIP and GZIP compatibility.
maxLog2WindowLength
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.noWrap
- If true, the header and trailer will not be generated.maxLog2WindowLength
- maximum window length.compressionValue
- 0 to 9 representing compression value; 0 being none; 9 being best.Method Detail |
---|
public void write(int data) throws IOException
write
in class OutputStream
data
- 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 OutputStream
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.
IOException
- If an I/O error occurs.public void flush() throws IOException
flush
in class OutputStream
IOException
- If an I/O error occurs.public void close() throws IOException
close
in class OutputStream
IOException
- 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