I have a text file containing several columns (obtained using Python's np.savetxt). I would like to read it in Java, store it as a multidimensional array, loop over the rows of the array and do some operations with the values retrieved at every iteration. I have no previous experience in Java, so would be very grateful if you could help me solve this. In Python, this would be something like
a, b, c = np.loadtxt(myfile, unpack=True)
for i in range(len(a)):
# do stuff with a[i], b[i], c[i]
I have found some implementations online that state that to read the file in Java I could use the following code. Unfortunately, it does not seem to work for me
public static void ReadFile(String[] args) {
BufferedReader abc = new BufferedReader(new FileReader(myfile));
List<String> lines = new ArrayList<String>();
while ((String line = abc.readLine()) != null) {
lines.add(line);
System.out.println(data);
}
abc.close();
}