package fr.tvbarthel.apps.simpleweatherforcast.utils;


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

public class URLUtils {

	public static String getAsString(String urlString) throws MalformedURLException, IOException {
		final URL url = new URL(urlString);
		final URLConnection connection = url.openConnection();
		connection.setUseCaches(false);
		connection.setConnectTimeout(5000);
		connection.setReadTimeout(10000);

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

@@ -49,16 +49,42 @@
 tils;%0A%0A%0A
+import android.util.Log;%0A%0A
 import j
@@ -160,32 +160,67 @@
 utStreamReader;%0A
+import java.net.HttpURLConnection;%0A
 import java.net.
@@ -266,39 +266,8 @@
 URL;
-%0Aimport java.net.URLConnection;
 %0A%0Apu
@@ -423,24 +423,25 @@
 tring);%0A
+%0A
 %09%09final 
 URLConne
@@ -432,16 +432,20 @@
 %09%09final 
+Http
 URLConne
@@ -450,17 +450,20 @@
 nection 
-c
+urlC
 onnectio
@@ -465,16 +465,36 @@
 ection =
+ (HttpURLConnection)
  url.ope
@@ -506,25 +506,28 @@
 ection();%0A%09%09
-c
+urlC
 onnection.se
@@ -549,49 +549,79 @@
 e);%0A
+%0A
 %09%09
-connecti
+//TODO handle the resp
 on
-.
 se
-tConnectTimeout(5000);%0A%09%09c
+ code.%0A%09%09Log.d(%22argonne%22, %22code -%3E%22 + urlC
 onne
@@ -630,28 +630,25 @@
 ion.
-s
+g
 etRe
-adTimeout(10000
+sponseCode()
 );%0A%0A
@@ -728,17 +728,20 @@
 mReader(
-c
+urlC
 onnectio
@@ -981,10 +981,11 @@
 g();%0A%09%7D%0A
+%0A
 %7D%0A

Change to HttpUrlConnection.