List of questions
Related questions
Question 76 - Associate Android Developer discussion
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();}
Your answer:
0 comments
Sorted by
Leave a comment first