File: getName()
/* * Output: * File Name:MainClass.java Path:MainClass.java Abs Path:C:\Java_Dev\workspace\cal\MainClass.java Parent:null does not exist is not writeable is not readable is a directoryfalse might be a named pipe is not absolute File last modified:0 File size:0 Bytes * * */ import java.io.File; public class MainClass { public static void main(String args[]) { File f1 = new File("MainClass.java"); System.out.println("File Name:" + f1.getName()); System.out.println("Path:" + f1.getPath()); System.out.println("Abs Path:" + f1.getAbsolutePath()); System.out.println("Parent:" + f1.getParent()); System.out.println(f1.exists() ? "exists" : "does not exist"); System.out.println(f1.canWrite() ? "is writeable" : "is not writeable"); System.out.println(f1.canRead() ? "is readable" : "is not readable"); System.out.println("is a directory" + f1.isDirectory() ); System.out.println(f1.isFile() ? "is normal file" : "might be a named pipe"); System.out.println(f1.isAbsolute() ? "is absolute" : "is not absolute"); System.out.println("File last modified:" + f1.lastModified()); System.out.println("File size:" + f1.length() + " Bytes"); } }