Java tutorial
import java.io.File; public class Attr { public static void main(String args[]) { File path = new File(args[0]); // grab command-line argument String exists = getYesNo(path.exists()); String canRead = getYesNo(path.canRead()); String canWrite = getYesNo(path.canWrite()); String isFile = getYesNo(path.isFile()); String isHid = getYesNo(path.isHidden()); String isDir = getYesNo(path.isDirectory()); String isAbs = getYesNo(path.isAbsolute()); System.out.println("File attributes for '" + args[0] + "'"); System.out.println("Exists : " + exists); if (path.exists()) { System.out.println("Readable : " + canRead); System.out.println("Writable : " + canWrite); System.out.println("Is directory : " + isDir); System.out.println("Is file : " + isFile); System.out.println("Is hidden : " + isHid); System.out.println("Absolute path : " + isAbs); } } private static String getYesNo(boolean b) { return (b ? "Yes" : "No"); } }