我用你的http://www.csdn.net/images/home/a001.jpg运行到注释的那一行时出现FileNotFoundException,我稍微改一下可以
URL url = new URL("http://www.163.net/images/020718/mail_fax.gif");
URLConnection connection = url.openConnection(); DataInputStream br = new DataInputStream(connection.getInputStream()); byte[] c = new byte[10240*10];
int ncount;
int inputcount = 0;
while ((ncount = br.read(c, inputcount, READ_ONCE_NUM)) > 0)
{
System.out.println("ncount="+ncount);
inputcount += ncount;
//缓冲区大小不够,不对这个URL的数据处理,直接返回
if ((inputcount + READ_ONCE_NUM) > INPUT_BUFFER_SIZE)
{
br.close();
return;
}
}
br.close();
URL url = new URL("http://www.163.net/images/020718/mail_fax.gif");
URLConnection connection = url.openConnection(); DataInputStream br = new DataInputStream(connection.getInputStream()); byte[] c = new byte[10240*10];
int ncount;
int inputcount = 0;
while ((ncount = br.read(c, inputcount, READ_ONCE_NUM)) > 0)
{
System.out.println("ncount="+ncount);
inputcount += ncount;
//缓冲区大小不够,不对这个URL的数据处理,直接返回
if ((inputcount + READ_ONCE_NUM) > INPUT_BUFFER_SIZE)
{
br.close();
return;
}
}
br.close();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货