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

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();
}

Download Printable PDF. VALID exam to help you PASS.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.