import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import java.util.stream.Stream; public class Main { public static void main(String[] args) { final String dir = "C:\\data\\projects\\"; final Path path = Paths.get(dir); final File file = path.toFile(); Stream.of(file.listFiles(File::isDirectory)) .forEach(System.out::println);; } }