import java.io.*; class fileInfo{ File fileToCheck; public static void main(String args[]) throws IOException{ if (args.length>0){ for (int i=0;i<args.length;i++){ fileToCheck = new File(args[i]); info(fileToCheck); } } else { System.out.PRintln("No file given."); } }
public void info (File f) throws IOException { System.out.println("Name: "+f.getName()); System.out.println("Path: "=f.getPath()); if (f.exists()) { System.out.println("File exists."); System.out.print((f.canRead() ?" and is Readable":"")); System.out.print((f.cnaWrite()?" and is Writeable":"")); System.out.println("."); System.out.println("File is " + f.lenght() = " bytes."); } else { System.out.println("File does not exist."); } } }