Posted on 2009-10-21 14:12
leekiang 阅读(327)
评论(0) 编辑 收藏 所属分类:
java 、
commons
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