public class SecureOutputStreamWriter
extends java.io.Writer
The encoding used by an instance of SecureOutputStreamWriter
may be specified by name. If the encoding is not specified, the default
encoding, defined by the system property file.encoding, will be
used.
Each invocation of a write method causes the encoding converter
to operate on the given characters. The resulting bytes are accumulated in a
buffer before being written to the underlying output stream. All temporary
data is wiped following its use, and the buffer is automatically wiped after
it is written to the OutputStream.
| Constructor and Description |
|---|
SecureOutputStreamWriter(java.io.OutputStream out)
Creates a
SecureOutputStreamWriter object that uses the default
character encoding. |
SecureOutputStreamWriter(java.io.OutputStream out,
java.lang.String enc)
Creates a
SecureOutputStreamWriter object that uses the
specified character encoding. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying
OutputStream. |
void |
flush()
Flushes the internal buffer to the
OutputStream before
flushing the OutputStream itself. |
java.lang.String |
getEncoding()
Returns the name of the character encoding being used by this writer.
|
void |
write(char c)
Securely writes a single character to the
OutputStream. |
void |
write(char[] ca,
int off,
int len)
Securely writes a portion of an array of characters to the
OutputStream. |
void |
write(java.lang.String s)
This method is not supported.
|
public SecureOutputStreamWriter(java.io.OutputStream out)
SecureOutputStreamWriter object that uses the default
character encoding.
out - the output-streampublic SecureOutputStreamWriter(java.io.OutputStream out,
java.lang.String enc)
throws java.io.UnsupportedEncodingException
SecureOutputStreamWriter object that uses the
specified character encoding.
out - the output-streamenc - the character encoding to be usedjava.io.UnsupportedEncodingException - thrown if the encoding is not supportedpublic void close()
throws java.io.IOException
OutputStream.
All data is automatically flushed before the output stream is closed.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Writerjava.io.IOException - thrown if the close was unsuccessfulpublic void flush()
throws java.io.IOException
OutputStream before
flushing the OutputStream itself.
flush in interface java.io.Flushableflush in class java.io.Writerjava.io.IOException - thrown if the flush was unsuccessfulpublic java.lang.String getEncoding()
public void write(char c)
throws java.io.IOException
OutputStream.
This method converts the character and then writes it to an internal buffer
if there is space. If there is not enough space, the buffer and then the
converted data are written to the OutputStream. All internal
temporary data is wiped before the method returns.
c - the characther to writejava.io.IOException - thrown if the write was unsuccessfulpublic void write(char[] ca,
int off,
int len)
throws java.io.IOException
OutputStream.
The method converts the characters and then writes them to an internal
buffer if there is space. If there is not enough space, the buffer and
then the converted data are written to the OutputStream.
ca is not wiped by this
method. All internal temporary data is wiped before the method
returns. Use the SecureUtils.wipe( char [] ) method
to destroy the input character array.write in class java.io.Writerca - the array of characters to writeoff - the offset from which to start writing characterslen - the number of characters to writejava.io.IOException - thrown if the write was unsuccessfulpublic void write(java.lang.String s)
throws java.io.IOException
Using a String as an argument would create a copy of the data
in memory that cannot be destroyed.
write in class java.io.Writers - the string to writejava.io.IOException