For example, we have a BufferedReader reader, associated with the json file through


For example, we have a BufferedReader reader, associated with the json file through

InputStreamReader.

To get a file data we can do this:
A . String line; try {
while ((line = reader.readLine()) != null) { builder.append(line);
}
JSONObject json = new JSONObject(builder.toString()); return json;
} catch (IOException | JSONException exception) { exception.printStackTrace();
}

B . JSONObject line; try {
while ((line = reader.readJSONObject ()) != null) { builder.append(line);
}
JSONObject json = new JSONObject(builder.toString()); return json;
} catch (IOException | JSONException exception) { exception.printStackTrace();
}
C . String line; try {
while ((line = reader.readLine()) != null) { builder.append(line);
}
JSONObject json = new JSONObject(builder.toString()); return json;
} catch (RuntimeException|ArrayIndexOutOfBoundsException exception) { exception.printStackTrace();
}

Answer: A

Leave a Reply

Your email address will not be published.