Skip to content

Instantly share code, notes, and snippets.

@GaneshSamarthyam
Last active September 8, 2019 12:57
Show Gist options
  • Save GaneshSamarthyam/6711c4b770e1357a40e816e336561a95 to your computer and use it in GitHub Desktop.
Save GaneshSamarthyam/6711c4b770e1357a40e816e336561a95 to your computer and use it in GitHub Desktop.
Simplifying conditional code
private static List<String> readListStringsFromCSVFile(String filePath) throws IOException {
List<String> fileEntries = new ArrayList<>();
BufferedReader br = new BufferedReader(new FileReader(filePath));
String line;
while ((line = br.readLine()) != null) {
fileEntries.add(line);
}
return fileEntries;
}
@GaneshSamarthyam
Copy link
Author

Simplified code here:
private static List readListStringsFromCSVFile(String filePath) throws IOException {
 return Files.lines(Paths.get(filePath)).collect(Collectors.toList());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment