Class Overview
This class wraps an output stream and a cipher so that write
methods
send the data through the cipher before writing them to the underlying output
stream.
The cipher must be initialized for the requested operation before being used
by a CipherOutputStream
. For example, if a cipher initialized for
encryption is used with a CipherOutputStream
, the CipherOutputStream
tries to encrypt the data writing it out.
Summary
Public Methods |
void
|
close()
Close this cipher output stream.
|
void
|
flush()
Flushes this cipher output stream.
|
void
|
write(byte[] b, int off, int len)
Writes the len bytes from buffer b starting at offset
off to this cipher output stream.
|
void
|
write(int b)
Writes the single byte to this cipher output stream.
|
[Expand]
Inherited Methods |
From class
java.io.FilterOutputStream
void
|
close()
Closes this stream.
|
void
|
flush()
Ensures that all pending data is sent out to the target stream.
|
void
|
write(byte[] buffer, int offset, int length)
Writes count bytes from the byte array buffer starting at
offset to the target stream.
|
void
|
write(int oneByte)
Writes one byte to the target stream.
|
|
From class
java.io.OutputStream
void
|
close()
Closes this stream.
|
void
|
flush()
Flushes this stream.
|
void
|
write(byte[] buffer, int offset, int count)
Writes count bytes from the byte array buffer starting at
position of
fset to this stream.
|
void
|
write(byte[] buffer)
Equivalent to write(buffer, 0, buffer.length) .
|
abstract
void
|
write(int oneByte)
Writes a single byte to this stream.
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
|
From interf
java.io.Closeable
abstract
void
|
close()
Closes the object and release any system resources it holds.
|
|
From interface
java.io.Flushable
abstract
void
|
flush()
Flushes the object by writing out any buffered data to the underlying
output.
|
|
From interface
java.lang.AutoCloseable
abstract
void
|
close()
Closes the object and release any system resources it holds.
|
|
Public Constructors
Creates a new CipherOutputStream
instance for an OutputStream
and a Cipher
.
Parameters
os
| the output stream to write data to. |
c
| the cipher to process the data with.
|
Protected Constructors
protected
CipherOutputStream
(OutputStream os)
Creates a new CipherOutputStream
instance for an OutputStream
without a cipher.
A NullCipher
is created to process the data.
Parameters
os
| the output stream to write the data to.
|
Public Methods
public
void
close
()
Close this cipher output stream.
On the underlying cipher doFinal
will be invoked, and any
buffered bytes from the cipher are also written out, and the cipher is
reset to its initial state. The underlying output stream is also closed.
public
void
flush
()
Flushes this cipher output stream.
public
void
write
(byte[] b, int off, int len)
Writes the len
bytes from buffer b
starting at offset
off
to this cipher output stream.
Parameters
b
| the buffer. |
off
| the offset to start at. |
len
| the number of bytes. |
public
void
write
(int b)
Writes the single byte to this cipher output stream.