Package org.bouncycastle.bcpg
Class BCPGOutputStream
java.lang.Object
java.io.OutputStream
org.bouncycastle.bcpg.BCPGOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,CompressionAlgorithmTags,PacketTags
Basic output stream.
-
Field Summary
Fields inherited from interface org.bouncycastle.bcpg.CompressionAlgorithmTags
BZIP2, UNCOMPRESSED, ZIP, ZLIBFields inherited from interface org.bouncycastle.bcpg.PacketTags
AEAD_ENC_DATA, COMPRESSED_DATA, EXPERIMENTAL_1, EXPERIMENTAL_2, EXPERIMENTAL_3, EXPERIMENTAL_4, LITERAL_DATA, MARKER, MOD_DETECTION_CODE, ONE_PASS_SIGNATURE, PADDING, PUBLIC_KEY, PUBLIC_KEY_ENC_SESSION, PUBLIC_SUBKEY, RESERVED, SECRET_KEY, SECRET_SUBKEY, SIGNATURE, SYM_ENC_INTEGRITY_PRO, SYMMETRIC_KEY_ENC, SYMMETRIC_KEY_ENC_SESSION, TRUST, USER_ATTRIBUTE, USER_ID -
Constructor Summary
ConstructorsConstructorDescriptionBase constructor - generate a PGP protocol encoding with old-style packets whenever there is an alternative for backwards compatibility.BCPGOutputStream(OutputStream out, boolean newFormatOnly) Base constructor specifying whether to use packets in the new format wherever possible.BCPGOutputStream(OutputStream out, int tag) Create a stream representing an old style partial object.BCPGOutputStream(OutputStream out, int tag, byte[] buffer) Create a new style partial input stream buffered into chunks.BCPGOutputStream(OutputStream out, int tag, long length) BCPGOutputStream(OutputStream out, int tag, long length, boolean oldFormat) Create a stream representing a general packet.BCPGOutputStream(OutputStream out, PacketFormat packetFormat) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidfinish()Finish writing out the current packet without closing the underlying stream.voidflush()Flush the underlying stream.static BCPGOutputStreamwrap(OutputStream out) If the argument is aBCPGOutputStream, return it.voidwrite(byte[] bytes, int off, int len) voidwrite(int b) voidvoidWrite a packet to the stream.Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
BCPGOutputStream
Base constructor - generate a PGP protocol encoding with old-style packets whenever there is an alternative for backwards compatibility.- Parameters:
out- output stream to write encoded data to.
-
BCPGOutputStream
Base constructor specifying whether to use packets in the new format wherever possible.- Parameters:
out- output stream to write encoded data to.newFormatOnly- true if use new format packets, false if backwards compatible preferred.
-
BCPGOutputStream
-
BCPGOutputStream
Create a stream representing an old style partial object.- Parameters:
tag- the packet tag for the object.- Throws:
IOException
-
BCPGOutputStream
public BCPGOutputStream(OutputStream out, int tag, long length, boolean oldFormat) throws IOException Create a stream representing a general packet.- Parameters:
out-tag-length-oldFormat-- Throws:
IOException
-
BCPGOutputStream
- Parameters:
tag-length-- Throws:
IOException
-
BCPGOutputStream
Create a new style partial input stream buffered into chunks.- Parameters:
out- output stream to write to.tag- packet tag.buffer- size of chunks making up the packet.- Throws:
IOException
-
-
Method Details
-
wrap
If the argument is aBCPGOutputStream, return it. Otherwise wrap it in aBCPGOutputStreamand then return the result.- Parameters:
out- output stream- Returns:
- BCPGOutputStream
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
writePacket
Write a packet to the stream.- Parameters:
p- packet- Throws:
IOException
-
writeObject
- Throws:
IOException
-
flush
Flush the underlying stream.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
finish
Finish writing out the current packet without closing the underlying stream.- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-