import java.io.File; /** This is a simple program to demonstrate how to use the methods of * File that you will use in the assignment. * Run this program with a single parameter, which is the name of a file * or directory or something that doesn't exist. */ public class SampleFile { private static void printList(File[] list, int index) { if (index < list.length) { System.out.println("name: " + list[index].getName() + " path: " + list[index].getPath()); printList(list, index+1); } } public static void main(String[] args) { if (args.length > 0) { String fileName = args[0]; File f = new File(fileName); if (! f.exists()) { System.out.println(f + " does not exist"); } else if (! f.isDirectory()) { System.out.println(f + " is a regular file"); } else { System.out.println(f + " is a directory"); File[] children = f.listFiles(); printList(children, 0); } } } }