我正在尝试将Apache Commons VFS与FTP一起使用。在我的FTP一个有文件和文件夹的一个结构:Apache Commons VFS:使用FTP
/
/test
/test/in
/test/in/file1.txt
/test/in/file2.txt
我需要连接和文件夹/读取测试的所有文件/在(它时刻都在变化)。代码:
FileSystemManager fsManager = null;
FileSystem fs = null;
FileSystemOptions opts = new FileSystemOptions();
fsManager = VFS.getManager();
FileObject path = fsManager.resolveFile("ftp://user:[email protected]/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不存在。 A进行了一些测试以检查文件类型:System.out.println(path.getType());
具有不同的路径。结果:
ftp://user:[email protected]/test - 文件
ftp://user:[email protected]/test/in - 虚
ftp://user:[email protected]/test/in/file1.txt - 文件
FileType.IMAGINARY意味着文件不存在。 任何想法如何使用FTP文件夹?