/* Copyright 2005 Daniel Cer (daniel.cer@cs.colorado.edu) This work is licensed under the Creative Commons Attribution-NonCommercial- ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA. */ import java.io.File; public class ListFiles { static void listFiles(String dirPath) { System.out.printf("Contents of \"%s\":\n", dirPath); File dir = new File(dirPath); for (String entry : dir.list()) { System.out.println(entry); } } static public void main(String[] args) { if (args.length != 1) { System.err.println("Usage:\n\tjava ListFiles (directory to list)\n"); System.exit(-1); } listFiles(args[0]); } }