例如:BufferedOutputStream bo=new BufferedOutputStream(s.getOutputStream());
BufferedInputStream bi=new BufferedInputStream(new FileInputStream(file));
byte[] arr=new byte[1024*1024];
int num=0;
while((num=bi.read(arr))!=-1)
{
bo.write(arr,0,num);
}
如果换成这样的
BufferedOutputStream bo=new BufferedOutputStream(s.getOutputStream());
BufferedInputStream bi=new BufferedInputStream(new FileInputStream(file));
byte[] arr=new byte[1024*1024];
int num=0;
while((num=bi.read(arr))!=0)
{
bo.write(arr,0,num);
}
下面的为啥错了??read(arr)=0和read(arr)=-1有啥区别,如果没读到不都是没有? |