Skip to content

Instantly share code, notes, and snippets.

@jamilsonjunior
Created August 28, 2017 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamilsonjunior/b0963d88ff964f2d2c39534807e4035d to your computer and use it in GitHub Desktop.
Save jamilsonjunior/b0963d88ff964f2d2c39534807e4035d to your computer and use it in GitHub Desktop.
getJsonArray
public JSONArray getJsonArray(String url) {
JSONArray jObj = null;
try {
String line, newjson = "";
URL urls = new URL(url);
BufferedReader reader = new BufferedReader(new
InputStreamReader(urls.openStream(), "UTF-8"));
while ((line = reader.readLine()) != null) {
newjson += line;
}
String json = newjson.toString();
jObj = new JSONArray(json);
} catch (Exception e) {
e.printStackTrace();
}
return jObj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment