public class test
{
public static void main(String args[]) throws Exception{
FileInputStream fin=new FileInputStream("F:\\sample.txt")
byte[] by=new byte[1000]
int size=fin.available()
if(size==0){
System.out.println("文件为空!!")
}else{
int len=fin.read(by)
System.out.println(new String(by,0,len))
}
}
}
关键是这一句,这一句能判断文件是否为空