Hi Guys sorry i'm ridiculously new to this but I'm attempting to read in a file and place into an array to work out the averages of the data in there, This is my code but every time i'm getting a NullException on " String[] row = file.readLine().split(" ");"
int nRows =652;
int nCols =7;
double data [][] = new double[nRows][nCols];
char map [][] = new char[nRows][nCols];
for (int i=1; i < nRows ; i++) {
String[] row = file.readLine().split(" ");
// below here ......
for (int j=1; j < nCols-1 ; j++) {
data[i][j] = Double.parseDouble(row[j]);
//put if no more data then stop.
}
}
file.close();
for (int i =0; i < nRows; i++) {
for (int j=0; j< nCols; j++) {
map[i][j] = '0';
}
}
for (int i =1; i < (nRows -1); i++) {
for (int j=1; j < (nCols -1); j++) {
double sum = data [i-1] [j] + data [i] [j-1] + data [i][j+1] + data [i+1][j];
double average = sum /4;
System.out.println(average);
}
}
for (int i=0; i <nRows; i++) {
for (int j=0; j <nCols; j++) {
System.out.print(map [i][j] + "");
}
for (int h = 1; h < (nRows -1); h++) {
for (int l =1; (l <nCols -1); l++) {
double sum = data [h-1] [h] + data [i] [h-1] + data [i] [h+1] + data [i+1] [h];
// this is average.
double average = sum /4;
System.out.println(average);
}
}
}
for (int i=0; i <nRows; i++) {
for (int j=0; j <nCols; j++) {
System.out.print(map [i][j] + " ");
}
System.out.println();
}
}
}