Class ChannelPositionInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
io.deephaven.util.channel.ChannelPositionInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public final class ChannelPositionInputStream extends FilterInputStream
  • Method Details

    • of

      public static InputStream of(SeekableByteChannel channel, InputStream in) throws IOException
      Wraps a channel-backed input stream in, ensuring upon close() that channel's SeekableByteChannel.position() has been advanced the exact amount of bytes that have been consumed from the resulting input stream. in is closed during close(); as such, the caller must ensure that closing in does not close channel. To remain valid, the caller must ensure that the resulting input stream isn't re-wrapped by any downstream code in a way that would adversely effect the position (such as wrapping the resulting input stream with buffering).
      Parameters:
      channel - the channel
      in - the input stream based on the channel
      Returns:
      a positional input stream
      Throws:
      IOException - if an IO exception occurs
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class FilterInputStream
      Throws:
      IOException