Hello all, I am new to GUI/Swing and am creating a simple application in Swing. As a part of my application, I want to persist the data, entered from the application. Currently I am using text file to save data using delimiters. I do not want to use any database, like oracle, mysql, ms access etc, in order to keep it simple. In this regard I have 2 questions: 1. Is writing data to and reading from a delimited flat files the only way? Updating data is a hassle. 2. Can XML be used to make things (write/update/delete records) easier? If yes, could you please send/direct me to sample code. Thanks Ashish
Is writing data to and reading from a delimited flat files the only way? Updating data is a hassle. No, it is not the only way. Can XML be used to make things (write/update/delete records) easier? If you don't know how to read/write to/from an XML document, initially, this can be difficult. In the long wrong it would prove to be better (maybe). I really don't think it would be any easier than a flat file. It would just be more robust. Depending on what you are persisting, the easiest way is to use the Properties object. It will allow you to read/write key/value pairs like: name=gregg bolinger age=29 location=wichita If this would work for you let me know and I will show you how it can be done using an InputStream to read the file into the properties object. Really easy stuff...
Thanks Greeg, I guess it will work fine for me. My file will have format more or less like name=gregg bolinger age=29 location=wichita name=ashish gupta age=30 location=bay area which I am currently storing in flat file as gregg bolinger^29^wichita ashish gupta^30^bay area I haven't have much coding exposure in XML but will not be too difficult to pick. I will really appreciate if you can give some pointers. Thanks Ashish
Hi, You can use XMLEncoder,Decoder classes in the package java.beans with JDK1.4.1. This provides very easy way to persist the data using the XML, but one constraints is that your class structure must follow the Java Beans architectute i.e. all the class members must have there getter/setters.
Hope this suggestion help you. Regards premier
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com