M. Black M. Black - 1 year ago 120
Java Question

Java nio, get all subfolders of some folder

How could I get all subfolders of some folder? I would use JDK 8 and nio.


for example, for folder "Designs.ipj" method should return {"Workspace", "Library1"}

Thank you in advance!

Answer Source
    List<Path> subfolder = Files.walk(folderPath, 1)

it will contains folderPath and all subfolders in depth 1. If you need only subfolders, just add:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download