|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
it.unimi.dsi.fastutil.io.MeasurableInputStream
it.unimi.dsi.fastutil.io.FastByteArrayInputStream
public class FastByteArrayInputStream
Simple, fast and repositionable byte-array input stream.
Warning: this class implements the correct semantics
of read(byte[], int, int) as described in InputStream.
The implementation given in ByteArrayInputStream is broken,
but it will never be fixed because it's too late.
| 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. |
long |
length()
Returns the overall length of this stream (optional operation). |
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)
Reads bytes from this byte-array input stream as specified in InputStream.read(byte[], int, int). |
void |
reset()
|
long |
skip(long n)
|
| Methods inherited from class java.io.InputStream |
|---|
read |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public byte[] array
public int offset
public int length
array starting from offset.
| Constructor Detail |
|---|
public FastByteArrayInputStream(byte[] array,
int offset,
int length)
array - the backing array.offset - the first valid entry of the array.length - the number of valid bytes.public FastByteArrayInputStream(byte[] array)
array - the backing array.| Method Detail |
|---|
public boolean markSupported()
markSupported in class java.io.InputStreampublic void reset()
reset in class java.io.InputStreampublic void close()
close in interface java.io.Closeableclose in class java.io.InputStreampublic void mark(int dummy)
mark in class java.io.InputStreampublic int available()
available in class java.io.InputStreampublic long skip(long n)
skip in class java.io.InputStreampublic int read()
read in class java.io.InputStream
public int read(byte[] b,
int offset,
int length)
InputStream.read(byte[], int, int).
Note that the implementation given in ByteArrayInputStream.read(byte[], int, int)
will return -1 on a zero-length read at EOF, contrarily to the specification. We won't.
read in class java.io.InputStreampublic long position()
RepositionableStream
position in interface MeasurableStreamposition in interface RepositionableStreampublic void position(long newPosition)
RepositionableStream
position in interface RepositionableStreamnewPosition - the new stream position.public long length()
MeasurableStream
length in interface MeasurableStream
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||