1 package net.mograsim.logic.model;
3 import java.io.IOException;
4 import java.io.UncheckedIOException;
5 import java.nio.file.Files;
6 import java.nio.file.Path;
7 import java.nio.file.Paths;
8 import java.util.function.Function;
9 import java.util.stream.Stream;
11 public class JavaJsonLineCounter
13 public static void main(String[] args) throws IOException
15 printLineCount("..", "java");
16 printLineCount("..", "json");
19 private static void printLineCount(String path, String filetype) throws IOException
21 long lineCount = Files.walk(Paths.get(path)).filter(Files::isRegularFile).filter(p -> p.toString().endsWith('.' + filetype))
22 .flatMap((Function<Path, Stream<String>>) p ->
26 return Files.lines(p);
30 throw new UncheckedIOException(e);
33 System.out.println("Total lines in " + filetype + " files: " + lineCount);