org.bouncycastle.bcpg
Class ArmoredOutputStream
java.lang.Object
|
+--java.io.OutputStream
|
+--org.bouncycastle.bcpg.ArmoredOutputStream
- public class ArmoredOutputStream
- extends java.io.OutputStream
Output stream that writes data in ASCII Armored format.
Note 1: close() needs to be called on an ArmoredOutputStream to write the final checksum. flush() will not do this as
other classes assume it is always fine to call flush() - it is not though if the checksum gets output.
Note 2: as multiple PGP blobs are often written to the same stream, close() does not close the underlying stream.
Constructor Summary |
ArmoredOutputStream(java.io.OutputStream out)
Constructs an armored output stream with default headers . |
ArmoredOutputStream(java.io.OutputStream out,
java.util.Hashtable headers)
Constructs an armored output stream with default and custom headers. |
Method Summary |
void |
addHeader(java.lang.String name,
java.lang.String value)
Set an additional header entry. |
void |
beginClearText(int hashAlgorithm)
Start a clear text signed message. |
void |
clearHeaders()
Remove all headers. |
void |
close()
Note: close() does not close the underlying stream. |
void |
endClearText()
|
void |
flush()
|
void |
resetHeaders()
Reset the headers to only contain a Version string (if one is present) |
void |
setHeader(java.lang.String name,
java.lang.String value)
Set an additional header entry. |
void |
write(int b)
|
Methods inherited from class java.io.OutputStream |
write, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
VERSION_HDR
public static final java.lang.String VERSION_HDR
ArmoredOutputStream
public ArmoredOutputStream(java.io.OutputStream out)
- Constructs an armored output stream with
default headers
.
- Parameters:
out
- the OutputStream to wrap.
ArmoredOutputStream
public ArmoredOutputStream(java.io.OutputStream out,
java.util.Hashtable headers)
- Constructs an armored output stream with default and custom headers.
- Parameters:
out
- the OutputStream to wrap.headers
- additional headers that add to or override the default
headers
.
setHeader
public void setHeader(java.lang.String name,
java.lang.String value)
- Set an additional header entry. Any current value(s) under the same name will be
replaced by the new one. A null value will clear the entry for name.
- Parameters:
name
- the name of the header entry.value
- the value of the header entry.
clearHeaders
public void clearHeaders()
- Remove all headers.
addHeader
public void addHeader(java.lang.String name,
java.lang.String value)
- Set an additional header entry. The current value(s) will continue to exist together
with the new one. Adding a null value has no effect.
- Parameters:
name
- the name of the header entry.value
- the value of the header entry.
resetHeaders
public void resetHeaders()
- Reset the headers to only contain a Version string (if one is present)
beginClearText
public void beginClearText(int hashAlgorithm)
throws java.io.IOException
- Start a clear text signed message.
- Parameters:
hashAlgorithm
-
endClearText
public void endClearText()
write
public void write(int b)
throws java.io.IOException
- Overrides:
write
in class java.io.OutputStream
flush
public void flush()
throws java.io.IOException
- Overrides:
flush
in class java.io.OutputStream
close
public void close()
throws java.io.IOException
- Note: close() does not close the underlying stream. So it is possible to write
multiple objects using armoring to a single stream.
- Overrides:
close
in class java.io.OutputStream