public class ReaderBuffer extends Object implements CharSequence
CharSequence that provides read-only random access to the data
input from a Reader.| Modifier and Type | Field and Description |
|---|---|
static int |
defaultBufferSize
Default buffer size = 4096
|
| Constructor and Description |
|---|
ReaderBuffer(Reader rdr)
Create a
ReaderBuffer with the contents taken from the nominated Reader,
using the default buffer size. |
ReaderBuffer(Reader rdr,
int bufferSize)
Create a
ReaderBuffer with the contents taken from the nominated Reader,
using the specified buffer size. |
| Modifier and Type | Method and Description |
|---|---|
char |
charAt(int index)
Get the character at the specified index.
|
int |
length()
Get the total length of the
CharSequence. |
CharSequence |
subSequence(int start,
int end)
Get a sub-sequence of this
CharSequence. |
String |
toString()
Get the string from this
CharSequence. |
static String |
toString(Reader rdr)
|
static String |
toString(Reader rdr,
int bufferSize)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitchars, codePointspublic static final int defaultBufferSize
public ReaderBuffer(Reader rdr, int bufferSize) throws IOException
ReaderBuffer with the contents taken from the nominated Reader,
using the specified buffer size. Read the data into a set of character arrays in an
ArrayList, so that it can be accessed by the CharSequence interface.rdr - the ReaderbufferSize - the buffer size to useIOException - if thrown by the Readerpublic ReaderBuffer(Reader rdr) throws IOException
ReaderBuffer with the contents taken from the nominated Reader,
using the default buffer size.rdr - the ReaderIOException - if thrown by the Readerpublic int length()
CharSequence.length in interface CharSequenceCharSequence.length()public char charAt(int index)
charAt in interface CharSequenceindex - the indexIndexOutOfBoundsException - if index less than 0 or greater than lengthCharSequence.charAt(int)public CharSequence subSequence(int start, int end)
CharSequence.subSequence in interface CharSequencestart - the start indexend - the end indexIllegalArgumentException - if the start or end index is invalidCharSequence.subSequence(int, int)public String toString()
CharSequence. The result is stored for subsequent
re-use.toString in interface CharSequencetoString in class ObjectCharSequenceObject.toString()public static String toString(Reader rdr) throws IOException
rdr - the ReaderStringIOException - if thrown by the Readerpublic static String toString(Reader rdr, int bufferSize) throws IOException
rdr - the ReaderbufferSize - the buffer sizeStringIOException - if thrown by the ReaderCopyright © 2020. All rights reserved.