|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
org.openqa.jetty.util.LineInput
public class LineInput
Fast LineInput InputStream. This buffered InputStream provides methods for reading lines of bytes. The lines can be converted to String or character arrays either using the default encoding or a user supplied encoding. Buffering and data copying are highly optimized, making this an ideal class for protocols that mix character encoding lines with arbitrary byte data (eg HTTP). The buffer size is also the maximum line length in bytes and/or characters. If the byte length of a line is less than the max, but the character length is greater, than then trailing characters are lost. Line termination is forgiving and accepts CR, LF, CRLF or EOF. Line input uses the mark/reset mechanism, so any marks set prior to a readLine call are lost.
Nested Class Summary | |
---|---|
static class |
LineInput.LineBuffer
Reusable LineBuffer. |
Field Summary |
---|
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
LineInput(InputStream in)
Constructor. |
|
LineInput(InputStream in,
int bufferSize)
Constructor. |
|
LineInput(InputStream in,
int bufferSize,
String encoding)
Constructor. |
Method Summary | |
---|---|
int |
available()
|
void |
destroy()
|
int |
getByteLimit()
Get the byte limit. |
InputStream |
getInputStream()
|
void |
mark(int limit)
|
boolean |
markSupported()
|
int |
read()
|
int |
read(byte[] b,
int off,
int len)
|
String |
readLine()
Read a line ended by CR, LF or CRLF. |
int |
readLine(byte[] b,
int off,
int len)
Read a line ended by CR, LF or CRLF. |
int |
readLine(char[] c,
int off,
int len)
Read a line ended by CR, LF or CRLF. |
LineInput.LineBuffer |
readLineBuffer()
Read a Line ended by CR, LF or CRLF. |
LineInput.LineBuffer |
readLineBuffer(int len)
Read a Line ended by CR, LF or CRLF. |
void |
reset()
|
void |
setByteLimit(int bytes)
Set the byte limit. |
long |
skip(long n)
|
Methods inherited from class java.io.FilterInputStream |
---|
close, read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LineInput(InputStream in)
in
- The underlying input stream.public LineInput(InputStream in, int bufferSize)
in
- The underlying input stream.bufferSize
- The buffer size and maximum line length.public LineInput(InputStream in, int bufferSize, String encoding) throws UnsupportedEncodingException
in
- The underlying input stream.bufferSize
- The buffer size and maximum line length.encoding
- the character encoding to use for readLine methods.
UnsupportedEncodingException
Method Detail |
---|
public InputStream getInputStream()
public void setByteLimit(int bytes)
bytes
- Limit number of bytes, or -1 for no limit.public int getByteLimit()
public String readLine() throws IOException
IOException
public int readLine(char[] c, int off, int len) throws IOException
c
- Character buffer to place the line into.off
- Offset into the buffer.len
- Maximum length of line.
IOException
public int readLine(byte[] b, int off, int len) throws IOException
b
- Byte array to place the line into.off
- Offset into the buffer.len
- Maximum length of line.
IOException
public LineInput.LineBuffer readLineBuffer() throws IOException
IOException
public LineInput.LineBuffer readLineBuffer(int len) throws IOException
len
- Maximum length of a line, or 0 for default
IOException
public int read() throws IOException
read
in class FilterInputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class FilterInputStream
IOException
public long skip(long n) throws IOException
skip
in class FilterInputStream
IOException
public int available() throws IOException
available
in class FilterInputStream
IOException
public void mark(int limit) throws IllegalArgumentException
mark
in class FilterInputStream
IllegalArgumentException
public void reset() throws IOException
reset
in class FilterInputStream
IOException
public boolean markSupported()
markSupported
in class FilterInputStream
public void destroy()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |