// Report some basic information about a file import java.io.*; // for File import java.util.*; public class FileInfo { public static void main(String[] args) throws FileNotFoundException { Scanner console = new Scanner(System.in); System.out.print("Enter a file name: "); String fileName = console.next(); File f = new File(fileName); System.out.println("exists returns " + f.exists()); if (!f.exists()) { throw new FileNotFoundException("File " + fileName + " does not exist."); } else { Scanner input = new Scanner(f); System.out.println("canRead returns " + f.canRead()); System.out.println("length returns " + f.length()); System.out.println("getAbsolutePath returns " + f.getAbsolutePath()); } } }