Is it safe to access a single file with multiple FileInputStream?

As described in the title, I would like to open several FileInputStream objects to access one file to receive data in another place. Is it safe to do this, thanks!

+5
source share
2 answers

This is fine as long as everything you do reads and none of your threads / threads place an exclusive lock on the file.

+2
source

Yes, technically it’s just reading the file at the same time from the point of view of the OS, and since it doesn’t change under your feet, you are good to go.

0
source

All Articles