import java.util.stream.Stream; import java.io.*; import java.nio.*; import java.nio.file.*; class Teine{ public static long failisuurus(Path tee){ try{ return Files.size(tee); } catch(Exception ex){ ex.printStackTrace(); } return -1; } public static void main(String[] arg) throws Exception{ System.out.println(Files.list(Paths.get(".")).count()); Files.list(Paths.get(".")).filter((f) -> f.toString().endsWith("java")). forEach((f) -> System.out.println(f.getFileName())); Files.list(Paths.get(".")).filter((f) -> f.toString().endsWith("java")). forEach(f -> System.out.println(failisuurus(f))); System.out.println(Files.list(Paths.get(".")). filter((f) -> f.toString().endsWith("java")). mapToLong((f) -> failisuurus(f)).sum()); } }