Skip to content

Instantly share code, notes, and snippets.

@josketres
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josketres/26e1d26d3bcf22dd4dca to your computer and use it in GitHub Desktop.
Save josketres/26e1d26d3bcf22dd4dca to your computer and use it in GitHub Desktop.
Nice java8 stuff
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