Source Code:
import java.io.File;
public class EmptyFileCheck {
public static void main(String[] args) {
try {
File f = new File(“test.txt”);
if(f.length() == 0) {
throw new Exception(“File is empty”);
}
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
}
Output:
