@ParametersAreNonnullByDefault public final class MoreFileSystems extends Object
FileSystem
s
This utility class offers methods to:
It is the user's responsibility to close
the
filesystems returned by these methods.
Unless otherwise noted, all methods in this class do not accept null
arguments and will throw a NullPointerException
if a null argument
is passed to them.
Modifier and Type | Method and Description |
---|---|
static FileSystem |
createZip(Path path)
Create a new zip file as a filesystem
|
static FileSystem |
openZip(Path path,
boolean readOnly)
Open a zip as a file system, read write or read only
|
static FileSystem |
readOnly(FileSystem fs)
Return a read only version of a filesystem, if necessary
|
@Nonnull @WillNotClose public static FileSystem openZip(Path path, boolean readOnly) throws IOException
Note that if it is determined that the zip file is not writable by the
current user, the file system will be read only even if the readOnly
argument is false
.
path
- the path to the zipreadOnly
- whether the zip should be opened read onlyFileSystemNotFoundException
- zip does not existIOException
- failed to open the path as a zip filesystem@Nonnull @WillNotClose public static FileSystem createZip(Path path) throws IOException
path
- the path to the zip to createFileAlreadyExistsException
- zip file already existsIOException
- other errors@Nonnull @WillNotClose public static FileSystem readOnly(FileSystem fs)
If the filesystem given as an argument is already read only (ie,
FileSystem.isReadOnly()
returns true), this
method will return the filesystem itself.
fs
- the filesystem