File.length(); FileInputStream stream = new FileInputStream("file"); int len = stream.avaiable();一般也可以用这个方法得到一个文件的长度。
new File("d:/demo.txt").length()/1024/1204 > 1
import java.io.*; public class TT1{ public static void main(String[] args) throws IOException{ try{ FileInputStream stream = new FileInputStream("ms13-4-2004.wrf"); int len = stream.available(); if(len/1024/1024>1){ System.out.println(len);} }catch(IOException e){System.out.println(e);} } } 文件ms13-4-2004.wrf要与程序在一个目录下
或者FileInputStream stream = new FileInputStream("d:/a.txt");
这个帖子也要50分,楼主我接点分哈,上面的同志都说完了,正确的哈.就是这种哈: new File("d:/demo.txt").length()/1024/1204 > 1
FileInputStream stream = new FileInputStream("file");
int len = stream.avaiable();一般也可以用这个方法得到一个文件的长度。
public class TT1{
public static void main(String[] args) throws IOException{
try{
FileInputStream stream = new FileInputStream("ms13-4-2004.wrf");
int len = stream.available();
if(len/1024/1024>1){
System.out.println(len);}
}catch(IOException e){System.out.println(e);}
}
}
文件ms13-4-2004.wrf要与程序在一个目录下
new File("d:/demo.txt").length()/1024/1204 > 1