Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes I/O and Streams and the fly likes What would be best solution? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "What would be best solution?" Watch "What would be best solution?" New topic
Author

What would be best solution?

Davy Kelly
Ranch Hand

Joined: Jan 12, 2004
Posts: 384
hey everyone,

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?

davy


How simple does it have to be???
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
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, ...


Ping & DNS - my free Android networking tools app
Davy Kelly
Ranch Hand

Joined: Jan 12, 2004
Posts: 384
hey ulf,

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 ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
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 ]
Davy Kelly
Ranch Hand

Joined: Jan 12, 2004
Posts: 384
Ulf,

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.

davy
 
Don't get me started about those stupid light bulbs.
 
subject: What would be best solution?
 
Similar Threads
Alternatives to arrays
Designing logic for parsing request data
Passing the contents of a file in a collection
How can i run a particular code for every 10 minutes
master/detail report in jsp