android 6.0使用httpUrlConnection代替httpClient

用HttpURLConnection代替
Java code
?
1
2
3
4
5
6
7
8
9
    URL url =  new  URL( "http://www.android.com/" );
    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    try  {
      InputStream in =  new  BufferedInputStream(urlConnection.getInputStream());
      readStream(in);
     finally  {
      urlConnection.disconnect();
    }
  }

猜你喜欢

转载自blog.csdn.net/mlsnatalie/article/details/52122673