开发者

How to store data of java array in Hard Disk, so as i can use it later?

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 ro开发者_开发知识库om'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!


It would probably be the best to serialize it.


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.


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.


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. But I still think a proper database is the right way to go ...)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜