Created
November 24, 2015 20:39
-
-
Save sax1johno/fcf89415ad17d05990da to your computer and use it in GitHub Desktop.
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
URL apod = new URL(APOD_URL); | |
HttpURLConnection urlConnection = (HttpURLConnection) apod.openConnection(); | |
InputStream in = new BufferedInputStream(urlConnection.getInputStream()); | |
BufferedReader br = new BufferedReader(new InputStreamReader(in)); | |
String jsonContent = br.readLine(); | |
apodData = new JSONObject(jsonContent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// You can also do the following if there's more than one line of JSON
StringBuilder jsonBuilder = new StringBuilder();
String line;
while (line = br.readLine() != null) {
jsonBuilder.append(line);
}
String jsonContent = jsonBuilder.toString();