Write a Java program that reads on file name from the user, then displays information about whether the file exists, whether the file is readable, whether the file is writable, the type of file and the length of the file in bytes?

import java.io.*;
import java.util.Scanner;
class FileInfo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String fname = sc.nextLine();
        File f = new File(fname);
        System.out.println("Exists: " + f.exists());
        System.out.println("Readable: " + f.canRead());
        System.out.println("Writable: " + f.canWrite());
        System.out.println("Type: " + (f.isDirectory() ? "Directory" : "File"));
        System.out.println("Length: " + f.length() + " bytes");
    }
}