// illustration of the class java.io.File: prints out the names of all // files in the directory from which the program was invoked // the class File includes a broad range of methods relating to files // and directories // note, however, that there is no direct way to effect a UNIX chdir() // system call; instead, to access a file in another directory, one must // make a new instance of File for that file, i.e. do something like // // File AnotherF = new File(full path name of that file) // import java.io.*; public class Dir { public static void main () { File F = new File("."); // in UNIX, recall that "." means the // current directory File[] Dirs = F.listFiles(); for (int I=0; I < Dirs.length; I++) System.out.println(Dirs[I]); } }