Created
September 3, 2014 21:24
-
-
Save arturotena/5408299567fa430cacc5 to your computer and use it in GitHub Desktop.
Quick-and-dirty way to count the lines of Java source code of a project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quick-and-dirty way to count the lines of Java source code of a project | |
System.out.println(Files.walk(Paths.get(".")) | |
.map(e -> e.toFile()) | |
.filter(f -> f.isFile() && f.canRead()) | |
.filter(f -> f.getName().endsWith(".java")) | |
.mapToLong(f -> { | |
try { return new BufferedReader(new FileReader( f )).lines().count(); | |
} catch (Exception ex) { throw new RuntimeException(ex); } | |
}) | |
.reduce(0, (acc, current) -> acc + current)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment