← all problems

populateListFromFile 🌶️🌶️

Write a method that takes a File, constructs a Scanner over it, and returns an ArrayList<String> containing every whitespace-separated token in the file, in order. Unlike an array, you do not need to know how many there are ahead of time! Keep reading with next() while hasNext() is true. For example, a file containing "cat", "dog", "bird" on separate lines should produce ["cat", "dog", "bird"].