請問一個關于視頻中while的問題
int bytes = 0;
?? ??? ?int j = 1;
while((bytes = in.read(buf,0,buf.length)) != -1){
?? ??? ??? ?for(int i = 0 ; i < bytes ; i++){
?? ??? ??? ??? ?System.out.print(Integer.toHexString(buf[i] & 0xff) + "? ");
?? ??? ??? ??? ?if(j++%10 == 0){
?? ??? ??? ??? ??? ?System.out.println();
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?}
這個返回的bytes,在讀取的文件確定的時候,應該是個固定的值吧?
那么視頻中的循環為什么不會發生死循環?
2015-04-07
不是固定的值,如果有數據,就是讀取的字節數,如果沒數據,就是-1