Skip to content

Tag: file

Java – splitting files by newline

How can I split file by newline? I’ve attempted to split by doing line.split(“\r?\n”) – but when I try printing the 0th index I get the entire file content when I was expecting just the first line. but if I try printing the result at index 0 I get the entire file content, when I expect…

File scanner only reading last number in file

Here is the code: I’m supposed to be figuring out the average of scores, while counting how many are in each letter grade. The problem is that it only reads the last number instead of ~80 different numbers. Answer Your if-else logic doesn’t get executed until the while loop ends and the entire fil…