|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
org.elkoserver.foundation.net.ChunkyByteArrayInputStream
public class ChunkyByteArrayInputStream
Input stream similar to ByteArrayInputStream but backed by an ongoing series of byte arrays that can be added to during the stream object's lifetime.
| Constructor Summary | |
|---|---|
ChunkyByteArrayInputStream()
Constructor. |
|
| Method Summary | |
|---|---|
void |
addBuffer(byte[] buf,
int length)
Be given a buffer full of input bytes. |
int |
available()
Get the number of bytes that can be read from this input stream without blocking. |
void |
preserveBuffers()
Copy any unread portions of the client buffer passed to addBuffer(byte[], int). |
int |
read()
Read the next byte of data from the input stream. |
String |
readASCIILine()
Read the next line of raw ASCII characters from the input stream. |
int |
readByte()
Read the next raw byte of data from the input stream. |
byte[] |
readBytes(int count)
Read a fixed number of bytes from the input stream. |
int |
readUTF8Char()
Read the next UTF-8 encoded character from the input stream. |
String |
readUTF8Line()
Read the next line of UTF-8 encoded characters from the input stream. |
String |
readUTF8String(int byteCount)
Read a string of UTF-8 encoded characters from the input stream. |
| Methods inherited from class java.io.InputStream |
|---|
close, mark, markSupported, read, read, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ChunkyByteArrayInputStream()
| Method Detail |
|---|
public void addBuffer(byte[] buf,
int length)
Note: this class assumes that it may continue to freely make direct
use of the contents of the byte buffer that is given to this method
(i.e., without copying it to internal storage) until preserveBuffers() is called; after that, the buffer contents may be
modifed externally. This is somewhat delicate, but eliminates a vast
amount of unnecessary byte array allocation and copying.
buf - The bytes themselves.length - Number of bytes in 'buf' to read (<= buf.length).
public int available()
throws IOException
available in class InputStreamIOExceptionpublic void preserveBuffers()
addBuffer(byte[], int). This has the side effect of passing responsibility for the
client buffer back to the client. This indirection minimizes
unnecessary byte array allocation and copying.
public int read()
throws IOException
read in class InputStreamIOException - if an incomplete line is in the buffers upon the
true end of input.
EOFException - if the true end of input is reached normally
public int readByte()
throws IOException
IOException - if the true end of input is reached normally
public byte[] readBytes(int count)
throws IOException
count - The number of bytes desired
IOException - if the true end of input is reached normally
public int readUTF8Char()
throws IOException
IOException - if an incomplete line is in the buffers upon
encountering the true end of input.
public String readASCIILine()
throws IOException
Takes ASCII characters from the buffers until a newline (optionally preceded by a carriage return) is read, at which point the line is returned as a String, not including the line terminator character(s).
EOFException - if the true end of input is reached.
IOException
public String readUTF8Line()
throws IOException
Takes UTF-8 characters from the buffers until a newline (optionally preceded by a carriage return) is read, at which point the line is returned as a String, not including the line terminator character(s).
EOFException - if the true end of input is reached.
IOException
public String readUTF8String(int byteCount)
throws IOException
byteCount - Number of bytes of "good" UTF-8 data known to be
available for reading.
IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||