zoukankan      html  css  js  c++  java
  • 访问URL

        URL url;
            try {
                url = new URL(address);
                HttpURLConnection con = (HttpURLConnection)url.openConnection();
                
                InputStream input = con.getInputStream();
                //SaxParser(input);
                //SAXPARSER
                
                StringBuilder sb = new StringBuilder();
                byte[] bytes = new byte[1024];
                int n;
                while((n = input.read(bytes,0,bytes.length)) != -1){
                    sb.append(new String(bytes, 0, n));
                    
                }
                
                
                
                
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

    2 HttpGet:

      

    HttpGet get = new HttpGet(url);
            HttpClient client = new DefaultHttpClient();
            HttpResponse httpResponse;
            StringBuilder builder = new StringBuilder();
            try {
                httpResponse = client.execute(get);
                HttpEntity httpEntity = httpResponse.getEntity();
                
                InputStream inputStream = httpEntity.getContent();
                //SaxParser(inputStream);
                //DomParser(inputStream);
                PullParser(inputStream);
            } catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }
  • 相关阅读:
    创建商品APP
    商品模块表结构分析
    sprintf 和 fprintf
    linux中sys目录
    linux中proc目录
    ioctl()函数
    ffmpeg下载安装
    【转】写给小白的实时音视频技术入门提纲
    linux常见目录解释
    linux nfs客户端开启失败解决办法
  • 原文地址:https://www.cnblogs.com/yk00/p/2891165.html
Copyright © 2011-2022 走看看