Pookie
Pookie

Reputation: 1279

Updating a text file from java

I am trying to have all debugging purposes written to a .txt file for my game. However in order to see anything updated I need to close and open the .txt file I am writing to. Is there a way or a type of program that will automatically update the file? Any help is extremely appreciated! I know about difference between flush and close function in case of filewriter in java where opening and closing the writer stops the writing but I need the file to update. I have no problem with continuous writing, it writes continuously just not updating while it is open

Upvotes: 0

Views: 102

Answers (2)

Kumaresan Perumal
Kumaresan Perumal

Reputation: 1956

You use log 4j framework that gives a lot flexibility to you to log debugging data

http://www.tutorialspoint.com/log4j/

Upvotes: 1

scadge
scadge

Reputation: 9723

For debugging purposes I think the best option will be to use some logging framework or Java's standard logging API to log to file - it will handle all file-related issues and all that you will have to do is just log with Logger.getLogger().debug( "some-message" );. For example, here is one of the tutorials: http://www.vogella.com/tutorials/Logging/article.html

Upvotes: 3

Related Questions