/*
* Output:
*
Directory of c:\
System.FormatException is a file
admin.lnk is a file
admiss.lnk is a file
AUTOEXEC.BAT is a file
...
...
*/
import java.io.File;
publicclass MainClass {
publicstaticvoid main(String args[]) {
String dirname = "c:\\";
File f1 = newFile(dirname);
if (f1.isDirectory()) {
System.out.println("Directory of " + dirname);
String s[] = f1.list();
for (int i = 0; i < s.length; i++) {
File f = newFile(dirname + "/" + s[i]);
if (f.isDirectory()) {
System.out.println(s[i] + " is a directory");
} else {
System.out.println(s[i] + " is a file");
}
}
} else {
System.out.println(dirname + " is not a directory");
}
}
}