public class Scanner
extends java.lang.Object
Constructor and Description |
---|
Scanner(java.io.InputStream inputStream,
java.nio.charset.Charset charset)
Construct a Scanner from an InputStream and supplied Charset.
|
Scanner(java.io.Reader reader)
Construct a Scanner from a Reader.
|
Scanner(java.lang.String s)
Construct a Scanner from a string.
|
Modifier and Type | Method and Description |
---|---|
void |
back()
Back up one character.
|
static int |
dehexchar(char c)
Get the hex value of a character (base16).
|
boolean |
end()
Determine if the scanner is at the end of the stream.
|
boolean |
more()
Determine if the source stream still contains characters that next()
can consume.
|
char |
next()
Get the next character in the source stream.
|
char |
next(char c)
Consume the next character, and check that it matches a specified
character.
|
java.lang.String |
next(int n)
Get the next n characters.
|
java.lang.String |
nextTo(char delimiter)
Get the text up but not including the specified character or the
end of line, whichever comes first.
|
java.lang.String |
nextTo(java.lang.String delimiters)
Get the text up but not including one of the specified delimiter
characters or the end of line, whichever comes first.
|
ParsePosition |
parsePosition()
Get an object representing the current parse position.
|
char |
skipTo(char to)
Skip characters until the next character is the requested character.
|
JSONException |
syntaxError(java.lang.String message)
Make a JSONException to signal a syntax error.
|
JSONException |
syntaxError(java.lang.String message,
java.lang.Throwable cause)
Make a JSONException to signal a syntax error.
|
JSONException |
syntaxError(java.lang.Throwable cause)
Make a JSONException to signal a syntax error.
|
java.lang.String |
toString()
Make a printable string of this Scanner.
|
public Scanner(java.io.Reader reader)
reader
- A reader.public Scanner(java.io.InputStream inputStream, java.nio.charset.Charset charset)
inputStream
- the input streamcharset
- the character set with which to interpret the
input streampublic Scanner(java.lang.String s)
s
- A source string.public void back() throws JSONException
JSONException
public static int dehexchar(char c)
c
- A character between '0' and '9' or between 'A' and 'F' or
between 'a' and 'f'.public boolean end()
true
if this scanner has reached the end of the stream,
otherwise false
public boolean more() throws JSONException
JSONException
public char next() throws JSONException
JSONException
public char next(char c) throws JSONException
c
- The character to match.JSONException
- if the character does not match.public java.lang.String next(int n) throws JSONException
n
- The number of characters to take.JSONException
- Substring bounds error if there are not
n characters remaining in the source stream.public char skipTo(char to) throws JSONException
to
- A character to skip to.JSONException
public java.lang.String nextTo(char delimiter) throws JSONException
delimiter
- A delimiter character.JSONException
public java.lang.String nextTo(java.lang.String delimiters) throws JSONException
delimiters
- A set of delimiter characters.JSONException
public JSONException syntaxError(java.lang.String message)
message
- The error message.public JSONException syntaxError(java.lang.Throwable cause)
cause
- The underlying cause.public JSONException syntaxError(java.lang.String message, java.lang.Throwable cause)
message
- The error message.cause
- The underlying cause.public ParsePosition parsePosition()
ParsePosition
representing the current location of
the scannerpublic java.lang.String toString()
toString
in class java.lang.Object