I having problem trying to write 3d array into the file. I don't understand why if I put in the exact Int then it able to write into my text file, but when I put in the array elements it doesn't. Please help thank you.
private static void writeData(int[][][] data, String string) throws Exception {
FileOutputStream os = new FileOutputStream("data.txt");
DataOutputStream out = new DataOutputStream(os);
int elements;
for (int f = 0; f < data.length; f++) {
for (int r = 0; r < data[f].length; r++) {
for (int c = 0; c < data[f][r].length; c++) {
elements = data[f][r][c];
out.writeInt(99); // THIS WORK
out.writeInt(elements); // THIS NOT WORK
System.out.print(elements + " ");
}
}
}
os.close();
out.close();
}