it.unimi.dsi.io
Class ByteBufferInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by it.unimi.dsi.fastutil.io.MeasurableInputStream
          extended by it.unimi.dsi.io.ByteBufferInputStream
All Implemented Interfaces:
RepositionableStream, java.io.Closeable

public class ByteBufferInputStream
extends MeasurableInputStream
implements RepositionableStream

A bridge between byte buffers and input streams.

The main usefulness of this class is that of making it possible creating input streams that are really based on a MappedByteBuffer.

Since:
1.2
Author:
Sebastiano Vigna

Constructor Summary
ByteBufferInputStream(java.nio.ByteBuffer byteBuffer)
          Creates a new byte-buffer input stream.
 
Method Summary
 int available()
           
 long length()
           
 void mark(int unused)
           
 boolean markSupported()
           
 long position()
           
 void position(long newPosition)
           
 int read()
           
 int read(byte[] b, int offset, int length)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.io.InputStream
close, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteBufferInputStream

public ByteBufferInputStream(java.nio.ByteBuffer byteBuffer)
Creates a new byte-buffer input stream.

Parameters:
byteBuffer - the underlying byte buffer.
Method Detail

available

public int available()
Overrides:
available in class java.io.InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream

mark

public void mark(int unused)
Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

read

public int read()
Specified by:
read in class java.io.InputStream

read

public int read(byte[] b,
                int offset,
                int length)
Overrides:
read in class java.io.InputStream

length

public long length()
            throws java.io.IOException
Specified by:
length in class MeasurableInputStream
Throws:
java.io.IOException

position

public long position()
              throws java.io.IOException
Specified by:
position in interface RepositionableStream
Specified by:
position in class MeasurableInputStream
Throws:
java.io.IOException

position

public void position(long newPosition)
              throws java.io.IOException
Specified by:
position in interface RepositionableStream
Throws:
java.io.IOException