What I am trying to do in this program is to pass a file that contains a series of tables as if it were an excel and arrange the data in the code so that the data is printed in the same way in the java.lang.NullPointerException that I get it comes out at the end of my impression, I don't really know what it is so I would like you to help me please. According to the program my error is on line 25.
try {
String[] data = new String[47];
String lineaTemporal;
File archivo = new File("Mat.txt");
FileReader fr = new FileReader(archivo);
BufferedReader br = new BufferedReader(fr);
String linea;
for (int i = 0; i < 47; i++) {
data[i] = br.readLine();
lineaTemporal = data[i];
String[] parts = lineaTemporal.split(" ");
for (String part1 : parts) {
System.out.print(part1);
System.out.print("\t");
}
System.out.println("");
}
//while ((linea = br.readLine()) != null) {
// System.out.println(linea);
//}
} catch (Exception e) {
e.printStackTrace();
}
Try this code:
In this way you are only going to fill the number of lines that the file has, you must be careful because if the file has more than 47 lines the array is broken.