本文介紹了檢查 FTP 服務器上的文件是否存在的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
有沒有一種有效的方法來檢查 FTP 服務器上的文件是否存在?我正在使用 Apache Commons Net.我知道我可以使用 FTPClient
的 listNames
方法來獲取特定目錄中的所有文件,然后我可以查看此列表以檢查給定文件是否存在,但我認為它效率不高,尤其是當服務器包含大量文件時.
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)
對于單個文件應該可以正常工作.
listFiles(String pathName)
should work just fine for a single file.
這篇關于檢查 FTP 服務器上的文件是否存在的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!