public static void main(String[] args) { try (Stream st1 = Files.find(Paths.get("/report"), 2, (p, a) -> p.toString().endsWith("txt")); Stream st2 = Files.walk(Paths.get("/report"), 2);) { st1.forEach(s -> System.out.println("Found: " + s)); st2.filter(s -> s.toString() .endsWith("txt")) .forEach(s -> System.out.println("Walked: " + s)); } catch (IOException ioe) { System.out.println("Exception"); } }
Found: \report\data\jundata.txtFound: \report\jun.txtWalked: \report\data\jundata.txtWalked: \report\jun.txt
Found: \report\data\jundata.txtFound: \report\jun.txtWalked: \report\data\jundata.txtWalked: \reportWalked: \report\jun.txtWalked: \report\data\
Found: \report\jun.txtWalked: \report\data\jundata.txtWalked: \report\jun.txt
Found: \report\jun.txtWalked: \reportWalked: \report\jun.txtWalked: \report\data\Walked: \report\data\jundata.txt