当我使用 Apache commons API 检索 FTP 文件时,我得到“。” 和“..”所有目录中的目录,包括子目录。我怎样才能避免这两个目录?有人可以建议我吗?
我的代码是:
client.changeWorkingDirectory("/");
String[] names = client.listNames();
for (String name : names) {
System.out.println("File Name = " + name);
}
FTPFile[] ftpFiles = client.listFiles(); // Want to eliminate "." and ".." files
output:
File Name = .
File Name = ..
File Name = .ftpquota
File Name = file1
File Name = file2