|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
org.apache.lucene.util.UnsafeByteArrayInputStream
public class UnsafeByteArrayInputStream
This class, much like ByteArrayInputStream uses a given buffer as a
source of an InputStream. Unlike ByteArrayInputStream, this class does not
"waste" memory by creating a local copy of the given buffer, but rather uses
the given buffer as is. Hence the name Unsafe. While using this class one
should remember that the byte[] buffer memory is shared and might be changed
from outside.
For reuse-ability, a call for reInit(byte[]) can be called, and
initialize the stream with a new buffer.
| Constructor Summary | |
|---|---|
UnsafeByteArrayInputStream()
Creates a new instance by not using any byte[] up front. |
|
UnsafeByteArrayInputStream(byte[] buffer)
Creates an UnsafeByteArrayInputStream which uses a given byte array as the source of the stream. |
|
UnsafeByteArrayInputStream(byte[] buffer,
int startPos,
int endPos)
Creates an UnsafeByteArrayInputStream which uses a given byte array as the source of the stream, at the specific range: [startPos, endPos) |
|
| Method Summary | |
|---|---|
int |
available()
|
void |
mark(int readlimit)
|
boolean |
markSupported()
|
int |
read()
Read a byte. |
void |
reInit(byte[] buffer)
Initialize the stream with a given buffer, using the default limits of [0, buffer.length) |
void |
reInit(byte[] buffer,
int startPos,
int endPos)
Initialize the stream with a given byte array as the source of the stream, at the specific range: [startPos, endPos) |
void |
reset()
Resets the stream back to its original state. |
| Methods inherited from class java.io.InputStream |
|---|
close, read, read, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public UnsafeByteArrayInputStream()
reInit
methods before you consume any byte from this instance.new byte[0] or something. Obviously in that case, one will
call either reInit methods before using the class.
public UnsafeByteArrayInputStream(byte[] buffer)
buffer - byte array used as the source of this stream
public UnsafeByteArrayInputStream(byte[] buffer,
int startPos,
int endPos)
buffer - byte array used as the source of this streamstartPos - first index (inclusive) to the data lying in the given bufferendPos - an index (exclusive) where the data ends. data @
buffer[endPos] will never be read| Method Detail |
|---|
public void mark(int readlimit)
mark in class InputStreampublic boolean markSupported()
markSupported in class InputStreampublic void reInit(byte[] buffer)
buffer - byte array used as the source of this stream
public void reInit(byte[] buffer,
int startPos,
int endPos)
buffer - byte array used as the source of this streamstartPos - first index (inclusive) to the data lying in the given bufferendPos - an index (exclusive) where the data ends. data @
buffer[endPos] will never be read
public int available()
throws IOException
available in class InputStreamIOException
public int read()
throws IOException
read in class InputStreamIOException
public void reset()
throws IOException
reset in class InputStreamIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||