日期:2014-05-20 浏览次数:20652 次
try {
URL url=new URL("http://www.baidu.com");
BufferedReader reader=new BufferedReader(new InputStreamReader(url.openStream()));
String s = "";
StringBuffer sb = new StringBuffer("");
while ((s = reader.readLine()) != null) {
sb.append(s);
}
reader.close();
String result=sb.toString();
System.out.print("网页所占字节数为:"+result.getBytes().length);
} catch (Exception e) {
// TODO: handle exception
}