Http Get using Android HttpURLConnection

The Solution to Http Get using Android HttpURLConnection is

Try getting the input stream from this you can then get the text data as so:-

    URL url;
    HttpURLConnection urlConnection = null;
    try {
        url = new URL("");

        urlConnection = (HttpURLConnection) url

        InputStream in = urlConnection.getInputStream();

        InputStreamReader isw = new InputStreamReader(in);

        int data =;
        while (data != -1) {
            char current = (char) data;
            data =;
    } catch (Exception e) {
    } finally {
        if (urlConnection != null) {

You can probably use other inputstream readers such as buffered reader also.

The problem is that when you open the connection - it does not 'pull' any data.

~ Answered on 2011-12-28 11:03:21

Most Viewed Questions: