Hi, I want to creat a record of user journey thought the game I'm coding, that would record a script of the user inputs to a separate log file, I am thinking of creating a userrecord class and the user input will be stored into a text file using filewriter class from java.io.package. Not sure if I write into the file with evey input or store the input into a stack and write at the end of the game. The former avoids the possibity of something goes wrong in the middle of the game, the later insures that problems of file changing directory or other errors (read many problems arise this way) Tom happening. Is there a good practice on doing this?
Thanks!

Recommended Answers

All 2 Replies

A log file is incredibly useful when things go wrong, provided it has been written to disk. So for me, waiting until the end to write it is not a good idea because a crash may prevent it being written. I would write all the records ditrectly to the file (or Java/OS buffer to be precise), maybe flushing the output buffer every "n" records just in case.

Ok, I'll go for that then! Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.