it.unimi.dsi.mg4j.io
Class FastByteArrayInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byit.unimi.dsi.mg4j.io.FastByteArrayInputStream
All Implemented Interfaces:
RepositionableStream

public class FastByteArrayInputStream
extends InputStream
implements RepositionableStream

Simple, fast and repositionable byte-array input stream.

Since:
0.6
Author:
Sebastiano Vigna

Field Summary
 byte[] array
          The array backing the input stream.
 int length
          The number of valid bytes in array starting from offset.
 int offset
          The first valid entry.
 
Constructor Summary
FastByteArrayInputStream(byte[] array)
          Creates a new array input stream using a given array.
FastByteArrayInputStream(byte[] array, int offset, int length)
          Creates a new array input stream using a given array fragment.
 
Method Summary
 int available()
           
 void close()
          Closing a fast byte array input stream has no effect.
 void mark(int dummy)
           
 boolean markSupported()
           
 long position()
          Returns the current stream position.
 void position(long newPosition)
          Sets the current stream position.
 int read()
           
 int read(byte[] b, int offset, int length)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.io.InputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

array

public byte[] array
The array backing the input stream.


offset

public int offset
The first valid entry.


length

public int length
The number of valid bytes in array starting from offset.

Constructor Detail

FastByteArrayInputStream

public FastByteArrayInputStream(byte[] array,
                                int offset,
                                int length)
Creates a new array input stream using a given array fragment.

Parameters:
array - the backing array.
offset - the first valid entry of the array.
length - the number of valid bytes.

FastByteArrayInputStream

public FastByteArrayInputStream(byte[] array)
Creates a new array input stream using a given array.

Parameters:
array - the backing array.
Method Detail

markSupported

public boolean markSupported()

reset

public void reset()

close

public void close()
Closing a fast byte array input stream has no effect.


mark

public void mark(int dummy)

available

public int available()

skip

public long skip(long n)

read

public int read()

read

public int read(byte[] b,
                int offset,
                int length)

position

public long position()
Description copied from interface: RepositionableStream
Returns the current stream position.

Specified by:
position in interface RepositionableStream
Returns:
the current stream position.

position

public void position(long newPosition)
Description copied from interface: RepositionableStream
Sets the current stream position.

Specified by:
position in interface RepositionableStream
Parameters:
newPosition - the new stream position.