How should you handle a FileSystemAlreadyExistsException
when calling FileSystems.newFileSystem?
One way would be to use the already created FileSystem (getFileSystem
), but then you could run into problems when the original creator closes it while you are still using it.
In case there is no generic answer to this question, then what about ZipFileSystem
s? Let's say I want to create one for a zip file and I do not know and cannot control whether a FileSystem already exists for this specific zip file.
Is there a reliable way to handle a FileSystemAlreadyExistsException
?
Sorry for being late here, but I just ran into this myself. There are several versions of the FileSystems.newFileSystem() call, some versions throw FileSystemAlreadyExistsException, some do not. I found that using the version that accepts a Path object did not throw the exception and allowed me to work around the issue I was having.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With