public void encryptFile(String fileName) {
FileInputStream fis=null;
File file=null;
try {
file=new File(fileName);
fis = new FileInputStream(file);
System.out.println(file.length());
System.out.println(fis.available());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
file.length();
fis.available(); 都是获取文件大小的方式 ,但是 file.length() 返回类型是 long fis.available() 返回类型是int ,在读取超过 Integer设置的最大值的时候会读取文件大小不准确。
转载于:https://blog.51cto.com/yjm199/1636567