Originally posted by laney coll:
I'm not really sure on how to output information to an output file
PrintWriter file = new PrintWriter(new BufferedWriter(new FileWriter("myfile.txt")));
...
synchronized(file) { file.println("foo bar"); }
Use a synchronized block because you will presumably be writing to "file" from more than one
thread. If you have a lot of print statements, you will probably want to wrap "file" in a synchronized object so you can dispense with the synchronized blocks.
- Peter