Hey great forum btw, Im just starting out with java and im using netbeans so please bear with me
I currently have a little programme for searching and adding houses to and from a txt file.
My first form to add a new house contains all the relevant details to that house i.e address , driveway etc.
I have used the netbeans gui builder to create a form with textfields that should contain the above infomation.
It also has a submit button, at the moment the submit button doesnt do anything, I want it to take the infomation from the text fields and write them to a file on my HDD.
I also have another form which asks which type of house you are looking for , the user then adds the relevant info into textfields and clicks submit, it then should browse the text file created earlier and then return matching results.
What is the basic coding i need to add for writing to a file and the reading from it
If you need to see any of my existing code then say and i will post it
That's for the fields. But how do you plan on delimiting each record (i.e. house)? For example, you could put a blank line between each house record. I'm not saying this is the best way to organize your text file. I'll assume you picked that layout for a reason (I would've chosen XML to store the data, but that's just my .02). But there may be better ways to store the info. For example:
In this sample data, there are three records (houses) delimited by a semi-colon(;). Each record's fields are delimited by a comma(,). If your file looked like this, then you could read in the entire string and parse it with StringTokenizer. You could then store the data in a data structure (e.g. HashMap) so you can operate on it.