所以这是我的功能
public String getPageResponseSize() {
try {
URLConnection con = new URL("http://" + url).openConnection();
BufferedInputStream bf = new BufferedInputStream(con.getInputStream());
int avail = bf.available();
System.out.println(avail);
return avail + "";
} catch (MalformedURLException ex) {
Logger.getLogger(JSoupParsing.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(JSoupParsing.class.getName()).log(Level.SEVERE, null, ex);
}
return "There is a problem currently with this feature";
}
我从这个问题中得到了一些参考 //关注Determine size of HTTP Response?
但是我得到一个错误的值,比较在"网络"中转移的值XXXKb检查元素的选项卡
我想计算一个近似相等的值来报告,帮助! (如果可以使用JSoup库解决方案,请告诉我refs)