Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DPM;
- import java.io.IOException;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.nio.file.Paths;
- import java.util.Collections;
- import java.util.List;
- import java.util.stream.Collectors;
- public class Main {
- public static void main(String[] args) throws IOException {
- String inputPath = "D:\\Coding\\Java\\Softuni\\Java Advanced - January 2019" +
- "\\04. Java-Advanced-Fiels-and-Directories-Lab\\04. Java-Advanced-" +
- "Files-and-Streams-Lab-Resources\\input.txt";
- String outputPath = "D:\\Coding\\Java\\Softuni\\Java Advanced - January 2019" +
- "\\04. Java-Advanced-Fiels-and-Directories-Lab\\04. Java-Advanced-" +
- "Files-and-Streams-Lab-Resources\\output.txt";
- Path path = Paths.get(inputPath);
- Path output = Paths.get(outputPath);
- List<String> lines = Files.readAllLines(path);
- lines = lines.stream().filter(l ->
- !l.isBlank()).collect(Collectors.toList());
- Collections.sort(lines);
- Files.write(output, lines);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement