@ThreadSafety(level=NOT_THREADSAFE) public final class JSONObjectReader extends java.lang.Object implements java.io.Closeable
Constructor and Description |
---|
JSONObjectReader(java.io.InputStream inputStream)
Creates a new JSON object reader that will read objects from the provided
input stream.
|
JSONObjectReader(java.io.InputStream inputStream,
boolean bufferInputStream)
Creates a new JSON object reader that will read objects from the provided
input stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this JSON object reader and the underlying input stream.
|
JSONObject |
readObject()
Reads the next JSON object from the input stream.
|
public JSONObjectReader(@NotNull java.io.InputStream inputStream)
inputStream
- The input stream from which the data should be read.public JSONObjectReader(@NotNull java.io.InputStream inputStream, boolean bufferInputStream)
inputStream
- The input stream from which the data should be
read.bufferInputStream
- Indicates whether to buffer the input stream.
This should be false
if the input stream
could be used for any purpose other than reading
JSON objects after one or more objects are read.@Nullable public JSONObject readObject() throws java.io.IOException, JSONException
null
if the end of the
end of the stream has been reached.java.io.IOException
- If a problem is encountered while reading from the
input stream.JSONException
- If the data readpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
- If a problem is encountered while closing the
underlying input stream.