Here you can find the source of listFiles(Path path)
static List<Path> listFiles(Path path) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; public class Main { static List<Path> listFiles(Path path) throws IOException { final List<Path> result = new ArrayList<>(); Files.walkFileTree(path, new SimpleFileVisitor<Path>() { @Override//from w ww . java 2 s. com public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { result.add(file); return FileVisitResult.CONTINUE; } }); return result; } }