package fr.tvbarthel.apps.simpleweatherforcast.utils;


import android.util.Log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class URLUtils {

	public static String getAsString(String urlString) throws MalformedURLException, IOException {
		final URL url = new URL(urlString);

		final HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
		urlConnection.setUseCaches(false);

		//TODO handle the response code.
		Log.d("argonne", "code ->" + urlConnection.getResponseCode());

		final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
		final StringBuilder stringBuilder = new StringBuilder();
		String line;
		while ((line = bufferedReader.readLine()) != null) {
			line += "\n";
			stringBuilder.append(line);
		}
		return stringBuilder.toString();
	}

}

@@ -60,24 +60,34 @@
 ort 
-android.util.Log
+org.apache.http.HttpStatus
 ;%0A%0Ai
@@ -217,47 +217,8 @@
 on;%0A
-import java.net.MalformedURLException;%0A
 impo
@@ -322,31 +322,8 @@
 rows
- MalformedURLException,
  IOE
@@ -370,16 +370,47 @@
 String);
+%0A%09%09String resultContent = null;
 %0A%0A%09%09fina
@@ -531,72 +531,12 @@
 %0A%0A%09%09
-//TODO handle the response code.%0A%09%09Log.d(%22argonne%22, %22code -%3E%22 + 
+if (
 urlC
@@ -562,20 +562,41 @@
 seCode()
-);%0A%0A
+ == HttpStatus.SC_OK) %7B%0A%09
 %09%09final 
@@ -704,16 +704,17 @@
 ()));%0A%09%09
+%09
 final St
@@ -760,24 +760,25 @@
 uilder();%0A%09%09
+%09
 String line;
@@ -778,16 +778,17 @@
 g line;%0A
+%09
 %09%09while 
@@ -837,16 +837,17 @@
 l) %7B%0A%09%09%09
+%09
 line += 
@@ -852,16 +852,17 @@
 = %22%5Cn%22;%0A
+%09
 %09%09%09strin
@@ -890,18 +890,29 @@
 ;%0A%09%09
+%09
 %7D%0A
+%09
 %09%09re
-turn
+sultContent =
  str
@@ -934,14 +934,43 @@
 ring();%0A
+%09%09%7D%0A%0A%09%09return resultContent;%0A
 %09%7D%0A%0A%7D%0A

Handle response code.