public class RandomFuncs {
public static void main(String[] args) {
readingFile();
}
public static void readingFile() {
String file = "coins.txt";
try {
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String line = bufferedReader.readLine();
//System.out.println(line);
while (line != null){ System.out.println(line);}
}
catch (IOException ex){
System.out.println("Unable to read to file " + file + ".Due to " + ex);
}
}
}
variable line always comes back as null and I'm not sure why . There is lines of text in the file but it's not being read.
Try putting the absolute file path into 'file'-variable.
Also
doesn't work, it prints 'line' until that particular string turns into null, which is never. Script just keeps printing the first line in the file forever.