File file = new File("D:/file.txt"); if(file.exists() && file.length)() == 0) { System.out.println("文件为空!"); }