Skip to content

Instantly share code, notes, and snippets.

@rschumm
Last active November 30, 2016 14:24
Show Gist options
  • Save rschumm/88299c8e4563158e2f5d4be28b752fe3 to your computer and use it in GitHub Desktop.
Save rschumm/88299c8e4563158e2f5d4be28b752fe3 to your computer and use it in GitHub Desktop.
Java 8 File- und Sortier-Zeugs
static Optional<Path> findXmlFile(File directory, String prefix) throws IOException {
if (!directory.exists()) {
return Optional.empty();
}
return Files
.find(directory.toPath(), 3,
(path, basicFileAttributes) -> path.toFile().getName().matches(prefix + ".*.XML"))
.sorted(Comparator.comparing(Path::getFileName).reversed()).findFirst();
}
File directory = new File("rschumm/");
Optional<Path> foundFile = Files.find(
directory.toPath(),
3,
(path, basicFileAttributes) -> path.toFile().getName().matches("Mitarbeiter.*.XML")
)
.sorted(Comparator.comparing(Path::getFileName))
.findFirst();
List<AgencyType> sortiert = agenturenListe.stream()
.sorted(Comparator.comparing(AgencyType::getAgencyType).reversed())
.sorted(Comparator.comparing(AgencyType::getCity))
.collect(Collectors.toList());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment