补零后,输出出现三位数
public static void printHexByByteArray(String fileName) throws IOException { FileInputStream in=new FileInputStream(fileName); byte[] buf=new byte[1*1024]; int b=in.read(buf, 0, buf.length); int j=1; for (int i = 0; i < b; 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(); }