-
-
Save antonarhipov/d9985974345056ac159724a9bc9b1005 to your computer and use it in GitHub Desktop.
LineReader
This file contains hidden or 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
final FileReader in = new FileReader(new File("lines.txt")); | |
BufferedReader reader = new BufferedReader(in); | |
final ArrayList<String> strings = new ArrayList<>(); | |
String line; | |
while ((line = reader.readLine()) != null) { | |
strings.add(line); | |
} | |
reader.close(); | |
String[] array = strings.toArray(new String[0]); | |
Arrays.sort(array); | |
for (String s : array) { | |
System.out.println(s); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment