List all files inside box folder
Hi,
I want to list files inside box folder,we are using box java api for this.
Can anyone help me to achieve this.I know how to list folders inside box folder, but i need help on listing files.
BoxFolder folder = new BoxFolder(api, boxFolderId);
for (BoxItem.Info itemInfo : folder) {
Something need to be done here.
}
Regards
Prasoon
-
The sample code you provided should return the items in a folder, which will include both folders and files.
The example below from our Java SDK documentation shows how get all folder items, and then check if each item returned is a file or folder.
BoxFolder folder = new BoxFolder(api, "id"); for (BoxItem.Info itemInfo : folder) { if (itemInfo instanceof BoxFile.Info) { BoxFile.Info fileInfo = (BoxFile.Info) itemInfo; // Do something with the file. } else if (itemInfo instanceof BoxFolder.Info) { BoxFolder.Info folderInfo = (BoxFolder.Info) itemInfo; // Do something with the folder. } }
Please sign in to leave a comment.
Comments
2 comments