com.upokecenter.text.CharacterReader
com.upokecenter.text.CharacterReader
public final class CharacterReader extends Object implements ICharacterInput
A general-purpose character input for reading text from byte streams and text strings. When reading byte streams, this class supports the UTF-8 character encoding by default, but can be configured to support UTF-16 and UTF-32 as well.
Constructors
Methods
int Read(int[] chars, int index, int length)
Reads a series of code points from a Unicode stream or a string.int ReadChar()
Reads the next character from a Unicode stream or a string.
Method Details
Read
public int Read(int[] chars, int index, int length)
Reads a series of code points from a Unicode stream or a string.
Specified by:
Read
in interfaceICharacterInput
Parameters:
chars
- An array where the code points that were read will be stored.index
- An index starting at 0 showing where the desired portion ofchars
begins.length
- The number of elements in the desired portion ofchars
(but not more thanchars
's length).
Returns:
- The number of code points read from the stream. This can be less
than the
length
parameter if the end of the stream is reached.
Throws:
NullPointerException
- The parameterchars
is null.IllegalArgumentException
- Eitherindex
orlength
is less than 0 or greater thanchars
's length, orchars
's length minusindex
is less thanlength
.
ReadChar
public int ReadChar()
Reads the next character from a Unicode stream or a string.
Specified by:
ReadChar
in interfaceICharacterInput
Returns:
- The next character, or -1 if the end of the string or stream was reached.