/**
* JSON object input stream.
*
* @param in
* the in
* @return the JSON object
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static JSONObject jsonObjectInputStream(InputStream in)
throws IOException {
String line;
BufferedReader br = new BufferedReader(new InputStreamReader(in,
Charset.forName("UTF-8")));
JSONObject json = new JSONObject();
while ((line = br.readLine()) != null) {
try {
json = new JSONObject(line);
} catch (JSONException e) {
return null;
}
}
return json;
}
A blog about the use of educational technology in language learning and teaching
Sunday, August 21, 2016
Convert InputStream to JSONObject
Labels:
Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment