Last active
November 30, 2016 14:24
-
-
Save rschumm/88299c8e4563158e2f5d4be28b752fe3 to your computer and use it in GitHub Desktop.
Java 8 File- und Sortier-Zeugs
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
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(); | |
} |
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
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(); |
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
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