Last active
September 8, 2019 12:57
-
-
Save GaneshSamarthyam/6711c4b770e1357a40e816e336561a95 to your computer and use it in GitHub Desktop.
Simplifying conditional code
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
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simplified code here:
private static List readListStringsFromCSVFile(String filePath) throws IOException {
return Files.lines(Paths.get(filePath)).collect(Collectors.toList());
}