为什么很多人这样判断流的末尾
都是根据inputstream.read()>0来判断的,实际上api上写-1才是流的末尾,而事实上也可能读到0的字节,此时并非是流的末尾。
我一直都用的是while((len=read.read())!=-1){...}
[解决办法]
我有用inputstream.read()>=0判断
[解决办法]
目测是这样的……
好在“The value byte is returned as an int in the range 0 to 255.”, 读到1111 1111并不会返回。
[解决办法]
是不是楼主搞错了,还是特例
去年我做网络这块时,都是用
while((len=read.read())!=-1){..}
做判断滴.....
[解决办法]
不知道别人一般是怎么用的,我一般写的是大于-1