This site requires JavaScript, please enable it in your browser!
Greenfoot back
quelea
quelea wrote ...

2011/5/31

Writing game/simulation data into a database or text file

quelea quelea

2011/5/31

#
Hello, I'm a newb so.... Can anyone help me get started figuring out how to add some code to my simulation which will write data from the simulation into a text file or excel spreadsheet so that I can access the data later and plot graphs etc? So my simulation is called crab-evolution and basically at every tick or thousandth tick or whatever I would like to record various parameters from the program (like the parameters that I currently have displayed in the game)....but how do you save these parameters into a seperate data file? Many thanks in advance for any help! My
quelea quelea

2011/6/10

#
*bump* been really busy trying to figure this out, but still struggling. I know I have all the ingredients there, as the data get written into an image for a logger display. But how could I log the data into a text file stored on my hard drive? Any help will be HUGELY appreciated!
davmac davmac

2011/6/10

#
You can use the standard Java file I/O classes and methods. The Java API documentation (all of it) is here. Look at the following classes: File (java.io.File), FileOutputStream (java.io.FileOutputStream), FileWriter (java.io.FileWriter), PrintWriter (java.io.PrintWriter). Also try googling "java file io" . ("io" means "input/output", also written as "i/o"). There are plenty of tutorials out there.
You need to login to post a reply.