The following code shows how to load a file in Java using java.io.File class and retrieve the file attributes.
import java.io.File; class LoadFile { public static void main(String args[]) { File file = new File("/home/radhakrishnan/t1.txt"); System.out.println("Is File exists : " + file.exists()); System.out.println("Is Directory : " + file.isDirectory()); System.out.println("Is File : " + file.isFile()); System.out.println("Is hidden file : " + file.isHidden()); System.out.println("Absolute Path : " + file.getAbsolutePath()); System.out.println("Parent : " + file.getParent()); System.out.println("Path : " + file.getPath()); System.out.println("FileName : " + file.getName()); System.out.println("Last Modified : " + file.lastModified()); System.out.println("File Length(in bytes) : " + file.length()); System.out.println("Can Read : " + file.canRead()); System.out.println("Can Write : " + file.canWrite()); System.out.println("Can Execute : " + file.canExecute()); } }