I am trying to write a list of numbers to Test.txt file which is located in the same directory as the java class file.

The program outputs the expected results to the Ide output window but when the file is checked after the program has terminated there is no data in the file - why is this?

Code :

public class IoTest {

final int MAX = 10;
int intValue;
String fileName = "Test.txt";

public IoTest () throws IOException {

Random rand = new Random();
File fileObj = new File(fileName);
FileWriter fw = new FileWriter(fileObj,true);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter pw = new PrintWriter(bw);

for (int line = 0;line <= MAX; line++){

for (int num = 0;num <= MAX; num++){

intValue = rand.nextInt (90)+(10);
pw.print(intValue + " ");
pw.write(intValue + " ");
System.out.println(intValue + " ");
}

pw.println();
}
pw.flush ();
pw.close ();
bw.close ();
fw.close ();

System.out.println ("debugging, file created : "+ fileName);
}
}