I'm not quite sure I know what you mean, but if you mean modifying the file at the same time, this is not an easy process. Actually, this is quite attractive, and there is no easy way to do this, from head to head you should:
- Decide whether the file is updated for each user, when someone modifies it, losing all changes or what to do in this case;
- If necessary, handle different and merge;
- Process synchronization for simultaneous recording to the same file, so when two users want to write this file, the content does not end with nonsense, for example, if one user wants to write "foo" and the other wants to write "bar", the content may be "fbaroo" without synchronization.
If you just want to open the file in read-only mode, all you have to do is open it through FileInputStream or something similar, an object that only allows read operations.
source share