Essentially I have a file of lines of integers. Each line has 9 digits. And I want to read the file. And then input each line into its an array. I want the array to be the same one each time. As I am going to do some processing to the array created from the first line. And then process the same array using a different line.
My input file is as follows:
8 5 3 8 0 0 4 4 0
8 5 3 8 0 0 4 2 2
And the current code that I am using is:
BufferedReader br = new BufferedReader(new FileReader("c:/lol.txt"));
Scanner sc = new Scanner(new File("c:/lol.txt"));
String line;
while (sc.hasNextLine()){
line = sc.nextLine();
int k = Integer.parseInt(line);
Now clearly I should be doing something more, I am just not really sure how to go about it.
Any help is greatly appreciated.
int k = Integer.parseInt(line);because a whole line can't be converted to one number. (There are many digits and spaces). Also you create aBufferedReaderand never use it. Is your question how to finish your program?line.split(" ");