Created
August 28, 2017 23:40
-
-
Save jamilsonjunior/b0963d88ff964f2d2c39534807e4035d to your computer and use it in GitHub Desktop.
getJsonArray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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