Okay… so I have a fairly interesting error… I declare a FileWriter called file, and I have it go through the following for loops:
for (int i = 0; i < a.radtot; i++) {
file.write("" + i * a.rstep);
for (int n = 0; n < a.timetot; n++) {
file.write("\t " + T[n][i]);
System.out.println(T[n][i] + " " + n + " " + i);
}
file.write("\n");
}
At the end of it, the System.out.println command prints what I expect it to, but the file cuts off midway… As in, instead of printing out everything System.out does… it stops in the middle. Does anyone happen to know why it would do that? Am I doing something wrong?
You need to call
close()on theFileWriterwhen you’re done with it. This forces all output to be actually written to disk (it could be left in a buffer otherwise).(I’m assuming you’ve omitted exception handling for brevity, so I have done the same. The
close()would ordinarily be in afinallyblock to ensure that it will always run.)