Java apache公共vfs,为文件夹中的每个文件创建新对象

时间:2017-11-20 19:12:29

标签: java apache ftp vfs

我正在尝试从与服务器的连接创建对象。我建立连接等。

//get files within folder
FileObject localFileObject = fsManager.resolveFile("path to folder containing files", options);
FileObject[] childrenFiles = localFileObject.getChildren();

//now I am trying to make a list of file objects, creating a new object for each file in the folder

List<File> fileList = new ArrayList<File>();


for (int i = 0; i < childrenFiles.length; i++) {                

        //here I want to create a new File object with id = i, 
        //and name = childrenFiles[ i ].getName().getBaseName();
        //I was trying to do: new File(id , name) and append this object 
        //to the list each iteration but no success

        }       

最后我想返回文件列表

return fileList;

我的列表是否正确创建,如何在每次循环后创建一个新对象并添加到列表中?

由于

0 个答案:

没有答案