tags:

views:

98

answers:

5

Goodevening Sir/Mam, I am trying to make a small program that will be used for hotel room reservation, please tell me how to store the data of room's status on disk, as when we open the program next time we'll get the data. Please help i am very new here. Have a nice day!

+2  A: 

One way to do this is serialize the array write it to a file. java-serialization has an example for serializing an object to a .txt file; you can adapt this code to serialize an array.

Justin Ethier
And a Map is already serializable, so only the room keys and status objects now need to be serializable:)
extraneon
+4  A: 

It would probably be the best to serialize it.

thelost
+2  A: 

The usual way of doing this in Java is to serialize the data structure / class. It's normally pretty easy to do as you just extend Serializable in the appropriate class.

Paul K.
A: 

Before you leap into implementing a hotel reservation system based on writing stuff into files, you need to consider using a relational database instead. A decent RDB will give better performance AND you won't have to worry about your program crashing with unsaved updates ... or (worse still) in the middle of writing the updates to disk.

The fact you are asking this question suggests (to me) that you are short on knowledge and experience. If this is a real project for a real hotel, stop now before someone gets hurt! (But if this is a student project, feel free to continue, and learn.)

Stephen C
A: 

Yes sir, I actuall don't know much. But studying alot to achive the perfection. I am doing this for a college project for a friend.

My question was like what should i study in java to achive this, i got only a month to do this.

Thanks for your answers, i know you all are very bussy people. Thanks Alot!