java - Reading multiple lines from FileReader -


* Edit because I can not use anything other than the scanner class.

I am reading in a lesson a file for Conway's Game of Life program that looks like this:

  ------------ --------------- --- ------------------------------ --------------- ------------- ---------------------- -------- ------- ----------------------- ------------ --------------- --- ------------------------------ --------------- ------------- ---------------------- -------- ------- ----------------------- ------------ --------------- --- ------------------------------ -------------------------------- ------------- XXX -------- ---- ----------- --- XXX ------------- ------------- XXX ---- -------- ------- ----------------------- ------------ --------------- --- ------------------------------ --------------- ------------- ---------------------- -------- ------- ----------------------- ------------ --------------- --- ----------------- ------------- ----------------- ------------- ------ - -------------------------------------------------- --- --------------------------------------------- ------------- ------------------------------  

I am trying to read all the letters in a string variable and then trying to parse the string in four arrays. How can I fix my code for reading all the lines, and not after I reach the end one?

  inputfile = jpnpain.shownputdialog ("where is the input file? C: \\ user \\ public \\ desktop \\ input.txt"); Scanner input = new scanner (new FileReader (input file)); String value = zero; While (input.hasNextLine ()) {values ​​= input.next (); } System.out.println (value);  

The path of the input file (the user has been entered in the popup) of the file No content

Here is a way to read the file line from a line


Comments