Arrange lines of a text file
You can probably do something like this as well:

Files.lines(path)


It gets all the lines from the file as a stream, then you can sort the string based on your logic and then collect the same in a list and write to the output file.

This answer gives you a functional programming approach. Most part of the method is self-explanatory.

Files.write(
            Paths.get(outFile), 
            Files.lines(Paths.get(path))
                .sorted(String::compareToIgnoreCase)
                .collect(Collectors.toList())
    );