Package jadex.common

Class BufferInputStream

java.lang.Object
java.io.InputStream
jadex.common.BufferInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class BufferInputStream extends InputStream
Class for wrapping an InputStream around a ByteBuffer. TODO: Optimize.
  • Field Details

    • buffer

      protected ByteBuffer buffer
      The buffer.
  • Constructor Details

    • BufferInputStream

      public BufferInputStream(ByteBuffer buffer)
      Creates a new InputStream from buffer.
      Parameters:
      buffer - The buffer.
  • Method Details

    • read

      public int read() throws IOException
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(byte[] b) throws IOException
      Reads an array from the buffer.
      Overrides:
      read in class InputStream
      Parameters:
      b - The array.
      Returns:
      Number of bytes read.
      Throws:
      IOException
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Reads an array from the buffer.
      Overrides:
      read in class InputStream
      Parameters:
      b - The array.
      off - The offset in the array.
      len - Number of bytes to read.
      Returns:
      Number of bytes read.
      Throws:
      IOException
    • wrap

      public static final BufferInputStream wrap(ByteBuffer buffer)
      Wraps a byte buffer.
      Parameters:
      buffer - The buffer.
      Returns:
      InputStream based on the buffer.