public class JSONReader
extends java.io.PushbackReader
Modifier and Type | Field and Description |
---|---|
static java.lang.Character |
EOF
A special Character constant to return if the reader hits EOF.
|
Constructor and Description |
---|
JSONReader(java.io.Reader in)
Create a new JSONReader with a default pushback buffer.
|
JSONReader(java.io.Reader in,
int size)
Create a new JSONReader with a specified Pushback buffer size.
|
Modifier and Type | Method and Description |
---|---|
int |
peek()
A special method to take advantage of the features of our
parent PushbackWriter.
|
int |
read()
Reads a single character.
|
int |
read(char[] buf,
int off,
int len)
Reads characters into a portion of an array.
|
java.lang.Object |
readValue()
Specialized read method to read JSON objects from the input
data.
|
void |
unread(char[] buf)
Pushes back an array of characters by copying it to the front
of the pushback buffer.
|
void |
unread(char[] buf,
int off,
int len)
Pushes back a portion of an array of characters by copying it
to the front of the pushback buffer.
|
void |
unread(int c)
Pushes back a single character by copying it to the front of
the pushback buffer.
|
public static final java.lang.Character EOF
public JSONReader(java.io.Reader in)
public JSONReader(java.io.Reader in, int size)
public java.lang.Object readValue() throws java.io.IOException, JSONException
java.io.IOException
- if a read error occurs.JSONException
- if the input is not properly formed JSON
according to RFC4627public int peek() throws java.io.IOException
java.io.IOException
- if a read error occurs.public int read() throws java.io.IOException
read
in class java.io.PushbackReader
java.io.IOException
- If an I/O error occurspublic int read(char[] buf, int off, int len) throws java.io.IOException
read
in class java.io.PushbackReader
buf
- Destination bufferoff
- Offset at which to start writing characterslen
- Maximum number of characters to readjava.io.IOException
- If an I/O error occurspublic void unread(int c) throws java.io.IOException
(char)c
.unread
in class java.io.PushbackReader
c
- The int value representing a character to be pushed backIf
- the pushback buffer is full, or if some other I/O
error occursjava.io.IOException
public void unread(char[] buf, int off, int len) throws java.io.IOException
cbuf[off]
, the character after that will have the value cbuf[off+1]
, and so forth.unread
in class java.io.PushbackReader
buf
- Character array to push backoff
- Offset of first character to push backlen
- Number of characters to push backjava.io.IOException
- If there is insufficient room in the
pushback buffer, or if some other I/O error occurspublic void unread(char[] buf) throws java.io.IOException
buf[0]
, the
character after that will have the value buf[1]
, and so
forth.unread
in class java.io.PushbackReader
buf
- Character array to push backjava.io.IOException
- If there is insufficient room in the
pushback buffer, or if some other I/O error occurs