請問一個(gè)關(guān)于視頻中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();
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?}
這個(gè)返回的bytes,在讀取的文件確定的時(shí)候,應(yīng)該是個(gè)固定的值吧?
那么視頻中的循環(huán)為什么不會(huì)發(fā)生死循環(huán)?
2015-04-07
不是固定的值,如果有數(shù)據(jù),就是讀取的字節(jié)數(shù),如果沒數(shù)據(jù),就是-1