A PGPCompressedDataGenerator is used by invoking one of the open functions to create an OutputStream that raw data can be supplied to for compression:
open(OutputStream, byte[]) to create a
packet consisting of a series of compressed data objects (partials).
A PGPCompressedDataGenerator is usually used to wrap the OutputStream
obtained from a
PGPEncryptedDataGenerator (i.e. to compress data prior to encrypting it).
Raw data is not typically written directly to the OutputStream obtained from a
PGPCompressedDataGenerator. The OutputStream is usually wrapped by a
PGPLiteralDataGenerator, which encodes the raw data prior to compression.
Once data for compression has been written to the constructed OutputStream, writing of the object
stream is completed by closing the OutputStream obtained from the #open() method, or
equivalently invoking close() on this generator.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private int | |
| private OutputStream | |
| private BCPGOutputStream |
| Access | Constructor and Description |
|---|---|
| public | PGPCompressedDataGenerator(int
the identifier of the algorithm)compression algorithm
to use.Construct a new compressed data generator. |
| public | PGPCompressedDataGenerator(int
the identifier of the algorithm, int compression algorithm
to use.the compression)Deflater compression level to use.Construct a new compressed data generator. |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements org. |
| private void | |
| public OutputStream | Returns: OutputStreamunderlying OutputStream to be used. out)Return an OutputStream which will save the data being written to the compressed object. |
| public OutputStream | Returns: the output stream to write data to.the stream to write compressed packets to. out, byte[] a buffer to use to buffer and write partial packets. The returned stream takes
ownership of the buffer and will use it to buffer plaintext data for compression. buffer)Return an OutputStream which will compress the data as it is written to it. |
| algorithm | back to summary |
|---|---|
| private int algorithm | |
| compression | back to summary |
|---|---|
| private int compression | |
| dOut | back to summary |
|---|---|
| private OutputStream dOut | |
| pkOut | back to summary |
|---|---|
| private BCPGOutputStream pkOut | |
| PGPCompressedDataGenerator | back to summary |
|---|---|
| public PGPCompressedDataGenerator(int algorithm) Construct a new compressed data generator.
| |
| PGPCompressedDataGenerator | back to summary |
|---|---|
| public PGPCompressedDataGenerator(int algorithm, int compression) Construct a new compressed data generator.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements org. Close the compressed object - this is equivalent to calling close on the stream returned by the open() method. | |
| doOpen | back to summary |
|---|---|
| private void doOpen() throws IOException | |
| open | back to summary |
|---|---|
| public OutputStream open(OutputStream out) throws IOException Return an OutputStream which will save the data being written to the compressed object. The stream created can be closed off by either calling close() on the stream or close() on the generator. Closing the returned stream does not close off the OutputStream parameter out.
| |
| open | back to summary |
|---|---|
| public OutputStream open(OutputStream out, byte[] buffer) throws IOException, PGPException Return an OutputStream which will compress the data as it is written to it. The stream will be written out in chunks (partials) according to the size of the passed in buffer. The stream created can be closed off by either calling close() on the stream or close() on the generator. Closing the returned stream does not close off the OutputStream parameter out. Note if the buffer is not a power of 2 in length only the largest power of 2 bytes worth of the buffer will be used. Note using this may break compatibility with RFC 1991 compliant tools. Only recent OpenPGP implementations are capable of accepting these streams.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides org. Implements java. |
| SafeCBZip2OutputStream | back to summary |
|---|---|
| public SafeCBZip2OutputStream(OutputStream output) throws IOException | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides org. Implements java. Doc from java. Closes this output stream and releases any system resources
associated with this stream. The general contract of
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. |
| SafeDeflaterOutputStream | back to summary |
|---|---|
| public SafeDeflaterOutputStream(OutputStream output, int compression, boolean nowrap) | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Writes remaining compressed data to the output stream and closes the underlying stream.
| |