我用printByByteArray方法,字节数组不足够大怎么也是读取整个文件?
public static void printByByteArray(String fileName)throws IOException{
FileInputStream in=new FileInputStream(fileName);
byte[] buf=new byte[10];
// int b=in.read(buf, 0, buf.length);
// int i=1;
// for(int j=0;j<b;j++){
// if(buf[j]<=0xf){
// System.out.print("0");
// }
// System.out.print(Integer.toHexString(buf[j])+" ");
// if(i++%10==0){
// System.out.println();
// }
// }
// in.close();
int b=0;
int i=1;
while((b=in.read(buf, 0, buf.length))!=-1){
for(int j=0;j<b;j++){
if((buf[j] & 0xff)<=0xf){
System.out.print("0");
}
System.out.print(Integer.toHexString(buf[j] & 0xff)+" ");
if(i++%10==0){
System.out.println();
}
}
}
in.close();
}