private String downloadUrl(String strUrl) throws IOException {
  String data="";
  InputStream iStream=null;
  HttpURLConnection urlConnection=null;
  try {
    URL url=new URL(strUrl);
    urlConnection=(HttpURLConnection)url.openConnection();
    urlConnection.connect();
    iStream=urlConnection.getInputStream();
    BufferedReader br=new BufferedReader(new InputStreamReader(iStream));
    StringBuffer sb=new StringBuffer();
    String line="";
    while ((line=br.readLine()) != null) {
      sb.append(line);
    }
    data=sb.toString();
    br.close();
  }
 catch (  Exception e) {
    Log.d("Exc. while down url",e.toString());
  }
 finally {
    iStream.close();
    urlConnection.disconnect();
  }
  return data;
}

private String downloadUrl ( String strUrl ) throws IOException { String data = "" ; InputStream iStream = null ; HttpURLConnection urlConnection = null ; try { URL url = new URL ( strUrl ) ; urlConnection = ( HttpURLConnection ) url . openConnection ( ) ; urlConnection . connect ( ) ; iStream = urlConnection . getInputStream ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( iStream ) ) ; StringBuffer sb = new StringBuffer ( ) ; String line = "" ; while ( ( line = br . readLine ( ) ) != null ) { sb . append ( line ) ; } data = sb . toString ( ) ; br . close ( ) ; } catch ( Exception e ) { Log . d ( "Exc. while down url" , e . toString ( ) ) ; } finally { iStream . close ( ) ; urlConnection . disconnect ( ) ; } return data ; }
a method to download json data from url
