import java.io.*;
/**
* User: Z.X.T
* Discript:显示目录
* Date: 2007-6-8
* Time: 9:14:18
*/
public class IoTest {
static String space = "|->";
public static void main(String[] args) {
File x = new File("D:" + File.separator + "logonApp");
if (x.exists()) {
printMenu(x, space);
}
if (args.length!=0) {
System.out.println(args[0]);
try {
FileReader myFileReader = new FileReader(args[0]);
BufferedReader myBufferedReader = new BufferedReader(myFileReader);
String myString;
System.out.println("------------BEGIN SHOW FILE "+new File(args[0]).getName().toUpperCase()+"----------------");
while ((myString = myBufferedReader.readLine()) != null) {
System.out.println(myString);
}
myFileReader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private static void printMenu(File x, String y) {
File[] tu = x.listFiles();
for (int q = 0; q < tu.length; q++) {
System.out.println(y + tu[q].getName());
if (tu[q].isDirectory()) {
printMenu(tu[q], "| " + y);
}
}
}
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/694276/viewspace-51411/,如需转载,请注明出处,否则将追究法律责任。