Here you can find the source of listFiles(final Path path)
public static List<Path> listFiles(final Path path) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; public class Main { public static List<Path> listFiles(final Path path) throws IOException { List<Path> paths = new ArrayList<>(); listFiles(path, paths);/*from w ww. j a va2 s . co m*/ return paths; } public static void listFiles(final Path path, final List<Path> paths) throws IOException { if (Files.isDirectory(path)) { List<Path> files = Files.list(path).collect(Collectors.toList()); for (Path path1 : files) { listFiles(path1, paths); } } else { paths.add(path); } } }