import java.io.*; public class DirectoryLister { public static void main(String args[]) { File entry; if (args.length == 0) { System.err.println("Please specify a directory name."); return; } entry = new File(args[0]); // user specified listDirectory(entry); } public static void listDirectory(File entry) { try { if (!entry.exists()) { System.out.println(entry.getName() + " not found."); return; } if (entry.isFile()) { // Write the pathname of the file System.out.println(entry.getCanonicalPath()); } else if (entry.isDirectory()) { // Create list of entries for this directory String[] fileName = entry.list(); if (fileName == null) return; for (int i = 0; i