Many programs reading single XML Java

Gregor :

My program uses a SAX parser (or maybe DOM parser) to read from an XML file located somewhere on a server. Now many people use my program, so many programs sometimes access this one XML file. Can there be problems if e.g. two users (which are using my program at the same time) want to read (only read and not write) the XML file at the same time? Do I have to consider anything special in my program or will this be handled by the OS?

Unfortunately I am not familiar with simultaneous access to files or if several people use my program and such a siutation occurs.

The program is built with Java 11.

Michael Kay :

It shouldn't cause a problem. It's not necessarily the most efficient way of doing it but for a low-throughput application it should work perfectly well (we have an in-house application that handles about 10 requests per day and this is exactly how we do it.)

If you decide to be a bit more ambitious and cache the parsed document in memory, you need to be aware that the default DOM implementation in Java is not thread-safe - even for read-only access. That's one of the reasons why I advise people to go with a third-party tree model such as JDOM2 or XOM.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive