java truevfs_Java-Apache Commons VFS:使用FTP
我正在嘗試通過FTP使用Apache Commons VFS.在我的FTP上,具有文件和文件夾的下一個結構:
/
/test
/test/in
/test/in/file1.txt
/test/in/file2.txt
我需要連接并從/ test / in文件夾中讀取所有文件(它一直在變化).碼:
FileSystemManager fsManager = null;
FileSystem fs = null;
FileSystemOptions opts = new FileSystemOptions();
fsManager = VFS.getManager();
FileObject path = fsManager.resolveFile("ftp://user:password@my.ftp.host/test/in/", opts);
fs = path.getFileSystem();
//prints Connection successfully established to /test/in
System.out.println("Connection successfully established to " + path.getName().getPath());
但是我找不到文件列表,因為它說/ test / in不存在.進行了一些檢查文件類型的測試:System.out.println(path.getType());不同的路徑.結果:
FileType.IMAGINARY表示該文件不存在.
任何想法如何使用ftp文件夾?
總結
以上是生活随笔為你收集整理的java truevfs_Java-Apache Commons VFS:使用FTP的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 干货丨总结5类面试官特点和应对方法
- 下一篇: 【LeetCode笔记】416. 分割等