Java HttpURLConnection获取HTML不完整
小弟用java做了一个小软件将公司内部重要的网页进行监控,方法是利用HttpURLConnection获取网页的HTML源码,在对源码进行分析,获取HMTL代码如下:
private String getHtml(String loginurl, String bm) {
try {
StringBuffer html = new StringBuffer();
URL url = new URL(loginurl);
setHaoma(System.currentTimeMillis());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
HttpURLConnection.setFollowRedirects(false);
conn.setDoOutput(true);
conn.setDoInput(true);
BufferedReader reader = new BufferedReader(new InputStreamReader(
conn.getInputStream()));
String line;
while (null != (line = reader.readLine())) {
line = new String(line.getBytes(), bm);
html.append(line.trim());
}
setHaomb(System.currentTimeMillis());
reader.close();
System.gc();
return html.toString();
} catch (MalformedURLException e) {
System.gc();
} catch (IOException e) {
System.gc();
} catch (Exception e) {
System.gc();
}
System.gc();
return "isnull";
}
可是当我用该函数获公司内部的一个用Cognos做的报表的HTML源码时,总是只获取前一部分,后部分不知道怎么也获取不了,Cognos报表的URL是:http://10.118.88.66/p2pd/servlet/dispatch?SM=query&search=defaultOutput(%2fcontent%2fpackage%5b%40name%3d%27GZDW_95598_IQD%27%5d%2freport%5b%40name%3d%2795598%20%e5%ae%a2%e6%9c%8d%e6%83%85%e5%86%b5_20091110%27%5d)&SA=propEnum,properties&ITEM=data&EA=&SS=queryOptions,options&dataEncoding=MIMECompressed&ES=&EM=&cv.id=_THIS_
但是用浏览器打开这个URL时能正常显示HTML源码的,小弟在此请教。