• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple debugger class

 
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}

 
reply
    Bookmark Topic Watch Topic
  • New Topic