問(wèn)題描述
有沒(méi)有一種有效的方法來(lái)檢查 FTP 服務(wù)器上的文件是否存在?我正在使用 Apache Commons Net.我知道我可以使用 FTPClient
的 listNames
方法來(lái)獲取特定目錄中的所有文件,然后我可以查看此列表以檢查給定文件是否存在,但我認(rèn)為它效率不高,尤其是當(dāng)服務(wù)器包含大量文件時(shí).
Is there an efficient way to check the existence of a file on a FTP server? I'm using Apache Commons Net. I know that I can use the listNames
method of FTPClient
to get all the files in a specific directory and then I can go over this list to check if a given file exists, but I don't think it's efficient especially when the server contains a lot of files.
推薦答案
listFiles(String pathName)
對(duì)于單個(gè)文件應(yīng)該可以正常工作.
listFiles(String pathName)
should work just fine for a single file.
這篇關(guān)于檢查 FTP 服務(wù)器上的文件是否存在的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!