Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void distinctSort(String inputPath, String outputPath) throws IOException {
- Files.lines(Paths.get(inputPath))
- .filter(s -> {
- try {
- Integer.parseInt(s);
- return true;
- } catch (NumberFormatException nfe) {
- return false;
- }
- })
- .map(Integer::parseInt)
- .distinct()
- .sorted()
- .forEachOrdered(s -> {
- try {
- RandomAccessFile out = new RandomAccessFile(outputPath, "rw");
- Files.write(Paths.get(outputPath), (s + "\n").getBytes(), StandardOpenOption.APPEND);
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement