0

I am trying to create an object from a connection to a server. I make the connection etc.

//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

        }       

At the end I want to return the list of files back

return fileList;

Is my List created correct and how do i make a new object each time the loop goes and add to list?

Thanks

DrDrizzle
  • 1
  • 4
  • It looks like the exact duplicate of the question ([java - Convert a FileObject into a File](https://stackoverflow.com/questions/18484197)), does not it? – Sergey Vyacheslavovich Brunov Nov 20 '17 at 19:27
  • will the array iv created work? my model for file has several fields I need to populate , id and name but i will want more in future. I read over your link. my constructor for file ispublic File(int id, String name) { super(); this.id = id; this.name = name; } will your link work to get me data for each required field – DrDrizzle Nov 21 '17 at 05:38
  • Could you please provide (post) a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve)? – Sergey Vyacheslavovich Brunov Nov 21 '17 at 11:56

0 Answers0