怎么輸出的時候字母前也加了0,還有ba[i]<0xf是什么意思
public static void chaozhuo1(String name) throws IOException{
FileInputStream fi=new FileInputStream(name);
byte[] ba=new byte[20*1024];
/*從fi中批量讀取字節,放入到ba【】字節數組中
* 從0位置開始,最多放ba.length個
*返回的是讀到的字節個數
*/
int num=fi.read(ba, 0, ba.length);//一次性讀完,說明字節數組夠大
int a=1;
for (int i = 0; i < num; i++) {
if(ba[i]<0xf){
System.out.print("0");
}
//byte類型8位,int32位,為了避免數據轉換錯誤,通過&0xff去掉高24位0
System.out.print(Integer.toHexString(ba[i]&0xff)+" ?");
if(a++%10==0){
System.out.println();
}
}
}
}