Package org.jppf.io

Class StreamOutputDestination

java.lang.Object
org.jppf.io.StreamOutputDestination
All Implemented Interfaces:
Closeable, AutoCloseable, IO, OutputDestination

public class StreamOutputDestination extends Object implements OutputDestination
Output destination backed by an OutputStream.
Author:
Laurent Cohen
  • Constructor Details

    • StreamOutputDestination

      public StreamOutputDestination(OutputStream os)
      Initialize this input source with the specified data.
      Parameters:
      os - the output stream to write to.
  • Method Details

    • write

      public int write(byte[] buffer, int offset, int len) throws Exception
      Write data to this output destination from an array of bytes.
      Specified by:
      write in interface OutputDestination
      Parameters:
      buffer - the buffer containing the data to write.
      offset - the position in the buffer where to start reading the data.
      len - the size in bytes of the data to write.
      Returns:
      the number of bytes actually written, or -1 if end of stream was reached.
      Throws:
      Exception - if an IO error occurs.
    • write

      public int write(ByteBuffer buffer) throws Exception
      Write data to this output destination from a byte buffer.
      Specified by:
      write in interface OutputDestination
      Parameters:
      buffer - the buffer containing the data to write.
      Returns:
      the number of bytes actually written, or -1 if end of stream was reached.
      Throws:
      Exception - if an IO error occurs.
    • writeInt

      public void writeInt(int value) throws Exception
      Write an int value to this output destination.
      Specified by:
      writeInt in interface OutputDestination
      Parameters:
      value - the value to write.
      Throws:
      Exception - if an IO error occurs.
    • close

      public void close() throws IOException
      Close this output destination and release any system resources associated with it.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - if an IO error occurs.