码迷,mamicode.com
首页 > 移动开发 > 详细

安卓必备,HttpUrlConnection

时间:2016-11-08 07:43:59      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:.com   new   blog   stat   input   pack   net   package   style   

package aaa;

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

public class aaa {

    public static void main(String[] args) throws IOException {
        URL url = new URL("https://123.sogou.com/");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        StringBuilder build = new StringBuilder();
        BufferedReader read = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String s;
        while ((s = read.readLine()) != null) {
            build.append(s + "\n");
        }
        String html=build.toString();
    }
}

 

安卓必备,HttpUrlConnection

标签:.com   new   blog   stat   input   pack   net   package   style   

原文地址:http://www.cnblogs.com/iwideal/p/6041264.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!