I seem to be having a randomly occurring issue that I hope someone can shed light on. I am reading in a file and outputting the contents. I have one test file, which can be read in 90% of the time. However, once in a while it incorrectly reports that the test file has 0 lines. Is there a reason this is happening? I would expect that it always reads in the contents. A bare bones example is shown below:
public void foo (Path path){
System.out.println("Exists?"+ Files.exists(path)); // Always says true
List<String>lines = Files.readAllLines(path);
System.out.println("NumLines:"+ lines.size()); // Sometimes 0, sometimes 7
}
I have also tried this with a BufferedReader(new FileReader(path.ToFile())) and get the same results