Home > other >  How to set and get some data from file in real time
How to set and get some data from file in real time

Time:11-09

I want to develop a system which show some numbers. These numbers are changed with some reasons.

The number of these numbers is just 5, so I think using database system is little bit too much. Therefore, I hope that the value stored in a file (XML or something) can be viewed and modified in real time on the server.

If this method is possible, please give me a small hint.

CodePudding user response:

There are many ways to read and write from a file. Especially if the file is a XML file. There are parsers and helper classes that can help you with it. Still, you would have to take care of closing the file, making sure that there is no inconsistent data and multithreading problems.

All these problems are (at a point) eliminated by using a DataBase system. If you think using a DB is too much, then use a smaller DB where the footprint is very small. For example H2.

Create a small table with your data and let the java driver take care of the complicated stuff for you. The other advantage is the speed that this DB delivers.

Do not forget, that there are strong reasons that people do not use files as DBs

  • Related