FileDocCategorySizeDatePackage
DirTree.javaAPI DocExample1013Wed Mar 07 22:56:10 GMT 2001None

DirTree

public class DirTree extends Object
DirTree - directory lister, like UNIX ls or DOS/VMS dir
author
Ian Darwin, ian@darwinsys.com
version
$Id: DirTree.java,v 1.3 2001/03/08 03:56:11 ian Exp $

Fields Summary
Constructors Summary
Methods Summary
private voiddoDir(java.lang.String s)
doDir - handle one filesystem object by name

		File f = new File(s);
		if (!f.exists()) {
			System.out.println(s + " does not exist");
			return;
		}
		if (f.isFile())
			doFile(f);
		else if (f.isDirectory()) {
			System.out.println("d " + f.getPath());
			String objects[] = f.list();

			for (int i=0; i<objects.length; i++)
				doDir(s + f.separator + objects[i]);
		} else
			System.err.println("Unknown: " + s);
	
private static voiddoFile(java.io.File f)
doFile - process one regular file.

		System.out.println("f " + f.getPath());
	
public static voidmain(java.lang.String[] argv)
Main program

		DirTree dt = new DirTree();
		if (argv.length == 0)
			dt.doDir(".");
		else for (int i = 0; i<argv.length; i++)
			dt.doDir(argv[i]);