HttpURLConnection 的使用

System.setProperty("sun.net.client.defaultConnectTimeout", "3000");
        System.setProperty("sun.net.client.defaultReadTime ", "3000");
        
        URL url1=null;
        try {
            url1 = new URL(url);
            HttpURLConnection urlCon = (HttpURLConnection)url1.openConnection();
            System.out.println(urlCon);
             BufferedReader in = null;
                try {
                  in = new BufferedReader(
                    new InputStreamReader(
                            urlCon.getInputStream()));
                  String inputLine;
                  while (
                    (inputLine = in.readLine()) != null) {
                    System.out.println(inputLine);
                  }
                } catch (IOException e) {
                  e.printStackTrace();
                }
                in.close();
                urlCon.disconnect();
        } catch (Exception e1) {
            e1.printStackTrace();
        }

http://tech.techweb.com.cn/archiver/tid-225522.html
http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/net/HttpURLConnection.html
http://zhuixue.javaeye.com/blog/385793

你可能感兴趣的:(HttpURLConnection 的使用)