通过FileInputStream来获取的文件大小:
public static void main(String[] args) {
FileInputStream fis= null;
try{
File f= new File("D:\\CentOS-6.5-x86_64-bin-DVD1.iso");
fis= new FileInputStream(f);
logger.info(fis.available());
}catch(Exception e){
logger.error(e);
} finally{
if (null!=fis){
try {
fis.close();
} catch (IOException e) {
logger.error(e);
}
}
}
}
下面是运行结果:
2147483647
它是Integer.MAX_VALUE,也就是有符号
整型能表示的最大数值。