|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream java.io.FilterInputStream java.io.BufferedInputStream org.melati.util.DelimitedBufferedInputStream
public class DelimitedBufferedInputStream
Like a BufferedInputStream
except it has a new function
readToDelimiter(byte[], int, int, byte[])
which will only read bytes upto the start
of any occurrence of the delimiter in the InputStream.
BufferedInputStream
Field Summary |
---|
Fields inherited from class java.io.BufferedInputStream |
---|
buf, count, marklimit, markpos, pos |
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
DelimitedBufferedInputStream(InputStream in)
Creates a DelimitedBufferedInputStream
and saves its argument, the input stream
in , for later use. |
|
DelimitedBufferedInputStream(InputStream in,
int size)
Creates a DelimitedBufferedInputStream
with the specified buffer size,
and saves its argument, the input stream
in , for later use. |
Method Summary | |
---|---|
int |
getBufferLength()
Used in tests. |
int |
getPotentialMatch()
Used in tests. |
int |
indexOf(byte[] data1,
byte[] data2,
int fromIndex)
Calculates length. |
int |
indexOf(byte[] data1,
byte[] data2,
int fromIndex,
int len)
Returns the index within data1 of the byte array data2. |
int |
readToDelimiter(byte[] b,
int off,
int len,
byte[] delim)
Reads bytes from this byte-input stream into the specified byte array, starting at the given offset, but we stop at the first occurrence of delim. |
Methods inherited from class java.io.BufferedInputStream |
---|
available, close, mark, markSupported, read, read, reset, skip |
Methods inherited from class java.io.FilterInputStream |
---|
read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DelimitedBufferedInputStream(InputStream in)
DelimitedBufferedInputStream
and saves its argument, the input stream
in
, for later use. An internal
buffer array is created and stored in buf
.
in
- the underlying input stream.public DelimitedBufferedInputStream(InputStream in, int size)
DelimitedBufferedInputStream
with the specified buffer size,
and saves its argument, the input stream
in
, for later use. An internal
buffer array of length size
is created and stored in buf
.
in
- the underlying input stream.size
- the buffer size.Method Detail |
---|
public int readToDelimiter(byte[] b, int off, int len, byte[] delim) throws IOException
This method implements the general contract of the corresponding
method of
the read
class. As an additional
convenience, it attempts to read as many bytes as possible by repeatedly
invoking the InputStream
read
method of the underlying stream. This
iterated read
continues until one of the following
conditions becomes true:
read
method of the underlying stream returns
-1
, indicating end-of-file, or
available
method of the underlying stream
returns zero, indicating that further input requests would block.
read
on the underlying stream returns
-1
to indicate end-of-file then this method returns
-1
. Otherwise this method returns the number of bytes
actually read.
Subclasses of this class are encouraged, but not required, to attempt to read as many bytes as possible in the same fashion.
b
- destination buffer.off
- offset at which to start storing bytes.len
- maximum number of bytes to read.delim
- the delimiter which we should stop reading at.
-1
if the end of
the stream has been reached.
IOException
- if an I/O error occurs.public int indexOf(byte[] data1, byte[] data2, int fromIndex)
Returns the index within data1 of the byte array data2. It starts looking in data1 at fromIndex and only considers len bytes of data1
data1
- array to look in.data2
- array to look for.fromIndex
- where to start looking from in data1.
public int indexOf(byte[] data1, byte[] data2, int fromIndex, int len)
data1
- array to look in.data2
- array to look for.fromIndex
- where to start looking from in data1.len
- maximum number of bytes of data1 to look in.
public int getBufferLength()
public int getPotentialMatch()
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |