为什么会出现已经是两位字节了还在前面补零的情况,如:0ce,正常情况应该是ce,而我的程序打印出来会出现0ce的情况。望大神给予指点
public static void printHexByByteArray2(String fileNames) throws IOException{
FileInputStream in = new FileInputStream(fileNames);
byte[] buf = new byte[64];
int bytes = 0;
int j = 1;
while((bytes = in.read(buf, 0, buf.length)) != -1){
for(int i=0;i<bytes;i++){
if(buf[i] <= 0xf){
System.out.print("0");
}
System.out.print(Integer.toHexString(buf[i] & 0xff)+" ");
if(j++ % 10 == 0){
System.out.println();
}
}
}
in.close();
}
这是错误图片: