making all the words lowercase

This commit is contained in:
2020-06-17 17:43:12 -05:00
parent 025e020e37
commit 96a7f1f00e

View File

@@ -14,7 +14,7 @@ public class RandomWordFileReader {
public RandomWordFileReader(String filename){
try(BufferedReader reader = Files.newBufferedReader(Path.of(filename));){
//This should use flatMap to make a string array from the line, and then turn the elements of that array into a stream, which goes to forEach
reader.lines().flatMap(line -> Arrays.stream(line.split("\\s+"))).forEach(word -> words.add(word));
reader.lines().flatMap(line -> Arrays.stream(line.split("\\s+"))).forEach(word -> words.add(word.toLowerCase()));
}catch (IOException ex){
System.err.println(ex);
}