Module 

Interface StreamSinkConduit

All Superinterfaces:
Conduit, SinkConduit
All Known Implementing Classes:
AbstractStreamSinkConduit, BlockingStreamSinkConduit, BufferedStreamSinkConduit, DeflatingStreamSinkConduit, FixedLengthStreamSinkConduit, MessageStreamSinkConduit, NullStreamSinkConduit, StreamSinkChannelWrappingConduit, SynchronizedStreamSinkConduit

public interface StreamSinkConduit extends SinkConduit
A sink (writable) conduit for byte streams.
Author:
David M. Lloyd
  • Method Details

    • transferFrom

      long transferFrom(FileChannel src, long position, long count) throws IOException
      Transfer bytes into this conduit from the given file.
      Parameters:
      src - the file to read from
      position - the position within the file from which the transfer is to begin
      count - the number of bytes to be transferred
      Returns:
      the number of bytes (possibly 0) that were actually transferred
      Throws:
      IOException - if an I/O error occurs
    • transferFrom

      long transferFrom(StreamSourceChannel source, long count, ByteBuffer throughBuffer) throws IOException
      Transfers bytes from the given channel source. On entry, throughBuffer will be cleared. On exit, the buffer will be flipped for emptying, and may be empty or may contain data. If this method returns a value less than count, then the remaining data in throughBuffer may contain data read from source which must be written to this channel to complete the operation.
      Parameters:
      source - the source to read from
      count - the number of bytes to be transferred
      throughBuffer - the buffer to copy through.
      Returns:
      the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached
      Throws:
      IOException - if an I/O error occurs
    • write

      int write(ByteBuffer src) throws IOException
      Writes a sequence of bytes to this conduit from the given buffer.
      Parameters:
      src - the buffer containing data to write
      Returns:
      the number of bytes written, possibly 0
      Throws:
      ClosedChannelException - if this conduit's SinkConduit.terminateWrites() method was previously called
      IOException - if an error occurs
    • write

      long write(ByteBuffer[] srcs, int offs, int len) throws IOException
      Writes a sequence of bytes to this conduit from the given buffers.
      Parameters:
      srcs - the buffers containing data to write
      offs - the offset into the buffer array
      len - the number of buffers to write
      Returns:
      the number of bytes written, possibly 0
      Throws:
      ClosedChannelException - if this conduit's SinkConduit.terminateWrites() method was previously called
      IOException - if an error occurs
    • writeFinal

      int writeFinal(ByteBuffer src) throws IOException
      Writes some data to the conduit, with the same semantics as write(java.nio.ByteBuffer). If all the data is written out then the conduit will have its writes terminated. Semantically this method is equivalent to: int rem = src.remaining(); int written = conduit.write(src); if(written == rem) { conduit.terminateWrites() }
      Parameters:
      src - The data to write
      Returns:
      The amount of data that was actually written.
      Throws:
      IOException
    • writeFinal

      long writeFinal(ByteBuffer[] srcs, int offset, int length) throws IOException
      Writes some data to the conduit, with the same semantics as write(java.nio.ByteBuffer[], int, int). If all the data is written out then the conduit will have its writes terminated.
      Parameters:
      srcs - The buffers from which bytes are to be retrieved
      offset - The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than srcs.length
      length - The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset
      Returns:
      The amount of data that was actually written
      Throws:
      IOException