I have a booking sheet that I am making, for my portfolio mainly.
I was wanting to know the best way of storing the data that will be put into JTextAreas, I previously tried to do this to a normal file like myfile.ser.
but I want to be able to store the data so that there is structure, so could my java program save to something like excel, or CSV file? would this be a good easy option? or is there better ways of storing the data?
can someone point me in the direction on how to do this? or show me a link to some page that can explain it further?
Can you give us an idea of the content you want to save? Is the data itself structured, or is just the text that's displayed in the JTextAreas?
If the former, then there are any number of file formats that could be used, depending on how it is structured: XLS, CSV, XML, Properties files, ...
Joined: Jan 12, 2004
well in the JTextAreas it will just be Strings I will save, and in my stats area just ints.
here is a pic of what I mean.
but I was wanting to save the per day, as I will need to use the stats at some point, I will have my date picking calendar get 2 dates and add all of the stats up between those dates picked.
thats why I was thinking either excel or CSV. if so can Java do it?
davy [ March 19, 2007: Message edited by: Davy Kelly ]
Joined: Mar 22, 2005
You could certainly use CSV or XLS (some helpful libraries are linked here), but since the data isn't really tabular that would be a bit of a hack.
I might use XML, either creating it directly through one of the DOM libraries (JAXP, XOM, JDOM, dom4j, ...) or -if your data structures are amenable to that- by way of the java.beans.XMLEncoder/XMLDecoder class. Examples of that can be found here under "Serialization". Don't let the term "serialization" confuse you - they write and read XML. [ March 19, 2007: Message edited by: Ulf Dittmer ]
Joined: Jan 12, 2004
thanks for your quick reply.
I dont know anything to do with Beans, so I think that would confuse me right now.
the strings would be amendable in the areas, say if someone cancels then they get taken out, or if they move their booking...
I looked at a couple of places, and most of them only give a certain amount of code (so I cant see what they are fully doing), or want me to purchase their app.
basically, I want to store the data, retrieve the data possibly amend the data & calculate some of the data.