Interface Output
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
ChannelOutput
,StreamOutput
The Output interface abstract the output target of
CryptoOutputStream
so that different implementation of output
can be used. The implementation Output interface will usually wraps an output
mechanism such as OutputStream
or
WritableByteChannel
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this output and releases any system resources associated with the under layer output.void
flush()
Flushes this output and forces any buffered output bytes to be written out if the under layer output method support.int
write
(ByteBuffer src) Writes a sequence of bytes to this output from the given buffer.
-
Method Details
-
close
Closes this output and releases any system resources associated with the under layer output.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an I/O error occurs.
-
flush
Flushes this output and forces any buffered output bytes to be written out if the under layer output method support. The general contract offlush
is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.- Throws:
IOException
- if an I/O error occurs.
-
write
Writes a sequence of bytes to this output from the given buffer.An attempt is made to write up to r bytes to the channel, where r is the number of bytes remaining in the buffer, that is,
src.remaining()
, at the moment this method is invoked.Suppose that a byte sequence of length n is written, where
0
<=
n<=
r. This byte sequence will be transferred from the buffer starting at index p, where p is the buffer's position at the moment this method is invoked; the index of the last byte written will be p+
n-
1
. Upon return the buffer's position will be equal to p+
n; its limit will not have changed.- Parameters:
src
- The buffer from which bytes are to be retrieved.- Returns:
- The number of bytes written, possibly zero.
- Throws:
IOException
- If some other I/O error occurs.
-