Welcome to the new Box Support website. Check out all the details here on what’s changed.

Comments

2 comments

  • Peter Christensen

    hi Ritika

    You can use the BoxItem.Info.getType() to work out the type of items in the folder. Either File,Folder or Weblink

    https://github.com/box/box-java-sdk/blob/main/doc/folders.md#get-a-folders-items

    For root folder you could do something like this:

    BoxFolder folder = new BoxFolder(api, "0");
    for (BoxItem.Info itemInfo : folder) {
    if (itemInfo.getType().equals("web_link") {
    BoxWeblink.Info weblinkInfo = (BoxWeblink.Info) itemInfo;
    // Do something with the weblink.
    } else if (itemInfo.getType().equals("file") { BoxFile.Info fileInfo = (BoxFile.Info) itemInfo; // Do something with the file. } else if (itemInfo.getType().equals("folder") { BoxFolder.Info folderInfo = (BoxFolder.Info) itemInfo; // Do something with the folder. } }

    Best regards
    Peter Christensen, Platform Solutions Engineer, Box

    0
    Comment actions Permalink
  • Ritika raina

    Thanks Peter Christensen

    0
    Comment actions Permalink

Please sign in to leave a comment.