wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes Simple debugger class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Simple debugger class" Watch "Simple debugger class" New topic
Author

Simple debugger class

Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

Hello All,
I want to write a simple debugger class that I can call to write debugging information to a file. I am getting some weird results from this code. Here is an example of something I am tried to send to a file:

I am only getting the last line in the debug.txt file. The other 3 lines above it do not get written. Does anyone know what I am doing wrong? Many thanks!
Barry

Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
It's because you're creating a new printwriter in the debug class every time you invoke write(). It may be, that even if you auto-flush, the file isn't really synced to disk, until the printwriter is closed;
I would change your class so that the the printwriter is created during the constructor
public Debug()
{
pw = new PrintWriter(new FileWriter("fred.txt", true),true);
}


I have no java certifications. This makes me a bad programmer. Ignore my post.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple debugger class