finddirectories.java

来自「用java开发的一个简单的ftp」· Java 代码 · 共 34 行

JAVA
34
字号
 import java.io.*;

public class FindDirectories
{
public static void main(String[] args)
{
// if no arguments provided, start at the parent directory
if (args.length == 0) args = new String[] { ".." };

try
{
File pathName = new File(args[0]);
String[] fileNames = pathName.list();

// enumerate all files in the directory
for (int i = 0; i < fileNames.length; i++)
{
File f = new File(pathName.getPath(), fileNames[i]);

// if the file is again a directory, call the main method recursively
if (f.isDirectory())
{
System.out.println(f.getCanonicalPath());
main(new String [] { f.getPath() });
}
}
}
catch(IOException e)
{
e.printStackTrace();
}
}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?