public class CipherOutputStream extends FilterOutputStream
Cipher
before sending it to the underlying output stream.out
Modifier | Constructor and Description |
---|---|
protected |
CipherOutputStream(OutputStream out)
Create a cipher output stream with no cipher.
|
|
CipherOutputStream(OutputStream out,
Cipher cipher)
Create a new cipher output stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this output stream, and the sink output stream.
|
void |
flush()
Flush any pending output.
|
void |
write(byte[] buf)
Write a byte array to the output stream.
|
void |
write(byte[] buf,
int off,
int len)
Write a portion of a byte array to the output stream.
|
void |
write(int b)
Write a single byte to the output stream.
|
public CipherOutputStream(OutputStream out, Cipher cipher)
out
- The sink for transformed data.cipher
- The cipher to transform data with.protected CipherOutputStream(OutputStream out)
out
- The sink for transformed data.public void close() throws IOException
This method will first invoke the Cipher.doFinal()
method of the
underlying Cipher
, and writes the output of that method to the
sink output stream.
close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterOutputStream
IOException
- If an I/O error occurs, or if an error is caused by
finalizing the transformation.public void flush() throws IOException
flush
in interface Flushable
flush
in class FilterOutputStream
IOException
- If an I/O error occurs.public void write(int b) throws IOException
write
in class FilterOutputStream
b
- The next byte.IOException
- If an I/O error occurs, or if the underlying cipher is
not in the correct state to transform data.public void write(byte[] buf) throws IOException
write
in class FilterOutputStream
buf
- The next bytes.IOException
- If an I/O error occurs, or if the underlying cipher is
not in the correct state to transform data.public void write(byte[] buf, int off, int len) throws IOException
write
in class FilterOutputStream
buf
- The next bytes.off
- The offset in the byte array to start.len
- The number of bytes to write.IOException
- If an I/O error occurs, or if the underlying cipher is
not in the correct state to transform data.