lucitas
2016-03-15 17:04
File file=new File("imooc\\a.txt");
FileInputStream in=new FileInputStream(file);
byte[] byteArray=new byte[(int)file.length];
in.read(byteArray);
for(byte b:byteArray){
if(b>=0&&b<=0xf){
System.out.print("0");
}
System.out.print(Integer.toHexString(b&0xff)+" ");
}问一下 为什么不直接获取文件的长度来 创建byte数组?
如果所处理的文件是个特别大的文件,那么这个字节数组就会太大了,多浪费内存!!整不好还能死机!!!
文件传输基础——Java IO流
133837 学习 · 1060 问题
相似问题
回答 2
回答 2