I'm trying to read a text file into a 30x30 char array. Scanner does not have a nextChar method, so I'm assuming I'm going to use next() and then split that line into chars? I'm hung up on using 3 for loops to do that though, one for the String, one for rows, and one for columns.
Here is my code so far..
public static void main(String[] args) throws FileNotFoundException {
final int cellSize = 30; // grid size
char[][] chargrid = new char[cellSize][cellSize];
File inputFile = new File("E:\\workspace\\Life2\\bin\\Sample input.txt");
Scanner in = new Scanner(inputFile);
char testchar;
while(in.hasNext()){
String s = in.next();
for (int i=0; i<s.length();i++){
testchar = s.charAt(i);
Now would I do the 2 for statements for the array row & columns and then set chargrid[i][j] = testchar for example?
Any help would be appreciated.
List<String>?List<String>and then examine thisList<String>to populate your 30x30 boolean array.