Last active
August 29, 2015 14:13
-
-
Save josketres/26e1d26d3bcf22dd4dca to your computer and use it in GitHub Desktop.
Nice java8 stuff
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
Comparator<Person> compareByName = Comparator.comparing(Person p -> p.getName()); | |
try (Stream<String> lines = Files.lines(Paths.get("text.txt"))) { | |
long count = lines | |
.flatMapToInt(String::codePoints) | |
.filter(c -> !Character.isSpaceChar(c)) | |
.count(); | |
System.out.printf("Count: %d", count); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
// Do some benchmarks | |
https://code.google.com/p/caliper/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment