|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.io.LineReader
public class LineReader
Utility class for reading out CRLF delimited lines from a SharedInputStream
.
Sample code
Field Summary | ||
---|---|---|
protected static int |
BUFFER_LENGTH
|
|
protected byte[] |
_buffer
|
|
protected int |
_bufferLength
|
|
protected int |
_bufferOffset
|
|
protected InputStream |
_stream
|
Constructor Summary | ||
---|---|---|
LineReader(InputStream stream)
Creates a new LineReader instance. |
Method Summary | ||
---|---|---|
byte[] |
getBuffer()
Deprecated. Only subclasses should access the underlying buffer, and they may directly access the protected _buffer field instead of using this method. |
|
int |
getBufferLength()
Deprecated. Only subclasses should access the buffer length, and they may directly access the protected _bufferLength field instead of using this method. |
|
int |
getBufferOffset()
Deprecated. Only subclasses should access the buffer offset, and they may directly access the protected _bufferOffset field instead of using this method. |
|
InputStream |
getStream()
Deprecated. Only subclasses should access the underlying stream, and they may directly access the protected _stream field instead of using this method. |
|
int |
lengthUnreadData()
Returns the number of bytes currently remaining in the underlying line buffer. |
|
byte[] |
readLine()
Read CRLF-delimited line from the stream. |
|
void |
setBufferLength(int bufferLength)
Deprecated. Only subclasses should access the buffer length, and they may directly access the protected _bufferLength field instead of using this method. |
|
void |
setBufferOffset(int bufferOffset)
Deprecated. Only subclasses should access the buffer offset, and they may directly access the protected _bufferOffset field instead of using this method. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int BUFFER_LENGTH
protected InputStream _stream
protected byte[] _buffer
protected int _bufferOffset
protected int _bufferLength
Constructor Detail |
---|
public LineReader(InputStream stream)
stream
- input stream from which to read the lines.Method Detail |
---|
public InputStream getStream()
public byte[] getBuffer()
public int getBufferOffset()
public int getBufferLength()
public void setBufferOffset(int bufferOffset)
bufferOffset
- New read/write position.public void setBufferLength(int bufferLength)
bufferLength
- New length for the underlying line buffer.public int lengthUnreadData()
0
before the first
invocation of readLine()
.
0
if
readLine()
has not yet been invoked.LineReader.readLine()
public byte[] readLine() throws IOException
Invoke this method to read bytes from the input stream until encountering a carriage-return line-feed pair marking the end of a line. The CRLF pair is stripped out of the stream, and not returned.
Note: This method will also attempt to properly build the stream even if it only streams a LF or a CR. For example, if the inputStream only provides an LF instead of CRLF for line endings this will not crash the method. Again, it will not return the LF or CR characters.
IOException
- If an I/O error occurs.
EOFException
- If the end of the stream has been reached.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal