Skip to content

Instantly share code, notes, and snippets.

@antonarhipov
Created March 9, 2017 18:53
Show Gist options
  • Save antonarhipov/d9985974345056ac159724a9bc9b1005 to your computer and use it in GitHub Desktop.
Save antonarhipov/d9985974345056ac159724a9bc9b1005 to your computer and use it in GitHub Desktop.
LineReader
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