Here you can find the source of fileListDeep(Path dir)
public static ArrayList<Path> fileListDeep(Path dir)
//package com.java2s; //License from project: LGPL import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Iterator; import java.util.stream.Stream; public class Main { public static ArrayList<Path> fileListDeep(Path dir) { try {//from w w w .jav a2s .c o m if (Files.exists(dir)) { Stream<Path> ds = Files.walk(dir); ArrayList<Path> dirList = new ArrayList<Path>(); Iterator<Path> it = ds.iterator(); while (it.hasNext()) { Path tp = it.next(); // discard directories if (!Files.isDirectory(tp)) { dirList.add(tp); } } ds.close(); return dirList; } else { return null; } } catch (IOException e) { System.out.println("Could not traverse directory"); } return null; } }