I have written a program which reads a file word by word, and counts the number of times each word appears. I am doing this using a Scanner. The issue comes up when I try to run my code on different machines. On my Windows 10 machine, the code runs through the entire file perfectly, but when the code is run on my MacBook, the Scanner stops reading the file part way through. I have included the part of the code that is looping through the file below.
Scanner s = new Scanner(theFile);
List<String> words = new LinkedList<>();
while (s.hasNextLine())
{
String word s.next().replaceAll("\\p{Punct}", "");
words.add(word.toLowerCase());
}
As I said, on Windows, the entire file is read, but on Mac, only a very small part is read. Also, I am using an SVN repository, and have made sure that the code, as well as the file being read is identical.