Search code examples
javaxmlparsingserializationsax

Serialize an object to XML and append for 1 day


So, I made another question "Save object data to a file" and I realized that I wasn't specific enough.

The program that I'm writing would do very well for itself to keep historical data of files, so my goal is something like this:

if timePolled > midnight
   if fileExists(fileName)
       appendData()
   else
       createFile(data_dd_mm_yy) // in xml
endif

Look at me being all VB above... ick

Anyways, the object itself looks something like this:

public class IHandler{
    public double currentLoad;
    public String currentPrice;
    public String configArgs[];
}

I'm not really sure how I would go about doing this.


Solution

  • For the serialization, Xstream (http://x-stream.github.io/) would do the trick. Then the rest you could handle with simple Java file IO.