現在、Java FTP ライブラリ (ftp4j) を使用して FTP サーバーにアクセスしています。サーバーのファイルカウントとディレクトリカウントを行いたいのですが、これは、ディレクトリ内のディレクトリ内のディレクトリ内のファイルなどをリストする必要があることを意味します.
これはどのように達成できますか?どんなヒントでも大歓迎です。
コードからの抜粋:
client = new FTPClient();
try {
client.connect("");
client.login("", "");
client.changeDirectory("/");
FTPFile[] list = client.list();
int totalDIRS = 0;
int totalFILES = 0;
for (FTPFile ftpFile : list) {
if (ftpFile.getType() == FTPFile.TYPE_DIRECTORY) {
totalDIRS++;
}
}
message =
"There are currently " + totalDIRS + " directories within the ROOT directory";
client.disconnect(true);
} catch (Exception e) {
System.out.println(e.toString());
}