慕慕4517339
2017-05-01 12:30
public static void ReadByteUtils(String name) throws IOException{
FileInputStream in = new FileInputStream(name);
byte[] bt = new byte[20*1024];
int a = in.read(bt, 0, bt.length);
int j = 1;
for(int i=0;i<=a-1;i++){
if(bt[i]<=0xf){
System.out.print("0");
}
System.out.print(Integer.toHexString(bt[i]&0xff)+" ");
if(j++%10==0){
System.out.println();
}
}
in.close();
}
单位数补0的if条件有问题!
可以这样写:
if((buf[i] & 0xff)<=0xf) {
System.out.print("0");
}
if判断里面加一个按位与 0xf
为什么补零没起到作用
文件传输基础——Java IO流
133836 学习 · 1060 问题
相似问题