【发布时间】:2012-10-19 17:34:24
【问题描述】:
这是我显示问题的简单测试代码:
URL u = new URL(someURLString);
URLConnection c = u.openConnection();
InputStream is = c.getInputStream();
int amount = c.getContentLength(); //gives 75830, which is correct
int r = 0;
while (is.read() != -1) //count input
r++;
//r is 65878, what the hell?
显然有数据丢失。谁能解释这种行为?
提前谢谢你
【问题讨论】:
-
你到底想做什么?
-
这只是测试代码来显示问题,但最后想通过页面逐行提取一些信息
标签: java inputstream