APIdia Launch Partner
Top Fields Constructors Methods
jdk.nio.zipfs

public Class ZipFileSystemProvider

extends FileSystemProvider
Class Inheritance
Imports
java.io.IOException, .InputStream, .OutputStream, java.net.URI, .URISyntaxException, java.nio.channels.AsynchronousFileChannel, .FileChannel, .SeekableByteChannel, java.nio.file.*, .DirectoryStream.Filter, java.nio.file.attribute.BasicFileAttributes, .FileAttribute, .FileAttributeView, java.nio.file.spi.FileSystemProvider, java.util.HashMap, .Map, .Set, java.util.concurrent.ExecutorService, java.util.zip.ZipException

Author
Xueming Shen, Rajendra Gutupalli, Jaya Hangal

Field Summary

Modifier and TypeField and Description
private final Map<Path, ZipFileSystem>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
checkAccess(Path path, AccessMode... modes)

Implements abstract java.nio.file.spi.FileSystemProvider.checkAccess.

Checks the existence, and optionally the accessibility, of a file.

public void
copy(Path src, Path target, CopyOption... options)

Implements abstract java.nio.file.spi.FileSystemProvider.copy.

Copy a file to a target file.

public void
createDirectory(Path path, FileAttribute<?>... attrs)

Implements abstract java.nio.file.spi.FileSystemProvider.createDirectory.

Creates a new directory.

public final void
delete(Path path)

Implements abstract java.nio.file.spi.FileSystemProvider.delete.

Deletes a file.

private boolean
public boolean
exists(Path path, LinkOption... options)

Overrides java.nio.file.spi.FileSystemProvider.exists.

Tests whether a file exists.

public <V extends FileAttributeView> V
getFileAttributeView(Path path, Class<V> type, LinkOption... options)

Implements abstract java.nio.file.spi.FileSystemProvider.getFileAttributeView.

Returns a file attribute view of a given type.

public FileStore
getFileStore(Path path)

Implements abstract java.nio.file.spi.FileSystemProvider.getFileStore.

Returns the FileStore representing the file store where a file is located.

public FileSystem
getFileSystem(URI uri)

Implements abstract java.nio.file.spi.FileSystemProvider.getFileSystem.

Returns an existing FileSystem created by this provider.

public Path
getPath(URI uri)

Implements abstract java.nio.file.spi.FileSystemProvider.getPath.

Return a Path object by converting the given URI.

public String
getScheme()

Implements abstract java.nio.file.spi.FileSystemProvider.getScheme.

Returns the URI scheme that identifies this provider.

private ZipFileSystem
public boolean
isHidden(Path path)

Implements abstract java.nio.file.spi.FileSystemProvider.isHidden.

Tells whether or not a file is considered hidden.

public boolean
isSameFile(Path path, Path other)

Implements abstract java.nio.file.spi.FileSystemProvider.isSameFile.

Tests if two paths locate the same file.

public void
move(Path src, Path target, CopyOption... options)

Implements abstract java.nio.file.spi.FileSystemProvider.move.

Move or rename a file to a target file.

public AsynchronousFileChannel
newAsynchronousFileChannel(Path path, Set<? extends OpenOption> options, ExecutorService exec, FileAttribute<?>... attrs)

Overrides java.nio.file.spi.FileSystemProvider.newAsynchronousFileChannel.

Opens or creates a file for reading and/or writing, returning an asynchronous file channel to access the file.

public SeekableByteChannel
newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs)

Implements abstract java.nio.file.spi.FileSystemProvider.newByteChannel.

Opens or creates a file, returning a seekable byte channel to access the file.

public DirectoryStream<Path>
newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter)

Implements abstract java.nio.file.spi.FileSystemProvider.newDirectoryStream.

Opens a directory, returning a DirectoryStream to iterate over the entries in the directory.

public FileChannel
newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs)

Overrides java.nio.file.spi.FileSystemProvider.newFileChannel.

Opens or creates a file for reading and/or writing, returning a file channel to access the file.

public FileSystem
newFileSystem(URI uri, Map<String, ?> env)

Implements abstract java.nio.file.spi.FileSystemProvider.newFileSystem.

Constructs a new FileSystem object identified by a URI.

public FileSystem
newFileSystem(Path path, Map<String, ?> env)

Overrides java.nio.file.spi.FileSystemProvider.newFileSystem.

Constructs a new FileSystem to access the contents of a file as a file system.

public InputStream
newInputStream(Path path, OpenOption... options)

Overrides java.nio.file.spi.FileSystemProvider.newInputStream.

Opens a file, returning an input stream to read from the file.

public OutputStream
newOutputStream(Path path, OpenOption... options)

Overrides java.nio.file.spi.FileSystemProvider.newOutputStream.

Opens or creates a file, returning an output stream that may be used to write bytes to the file.

public <A extends BasicFileAttributes> A
readAttributes(Path path, Class<A> type, LinkOption... options)

Implements abstract java.nio.file.spi.FileSystemProvider.readAttributes.

Reads a file's attributes as a bulk operation.

public Map<String, Object>
readAttributes(Path path, String attributes, LinkOption... options)

Implements abstract java.nio.file.spi.FileSystemProvider.readAttributes.

Reads a set of file attributes as a bulk operation.

public <A extends BasicFileAttributes> A
readAttributesIfExists(Path path, Class<A> type, LinkOption... options)

Overrides java.nio.file.spi.FileSystemProvider.readAttributesIfExists.

Reads a file's attributes as a bulk operation if it exists.

pack-priv void
public void
setAttribute(Path path, String attribute, Object value, LinkOption... options)

Implements abstract java.nio.file.spi.FileSystemProvider.setAttribute.

Sets the value of a file attribute.

private static ZipPath
protected Path
Inherited from java.nio.file.spi.FileSystemProvider:
createLinkcreateSymbolicLinkdeleteIfExistsinstalledProviders

Field Detail

filesystemsback to summary
private final Map<Path, ZipFileSystem> filesystems

Constructor Detail

ZipFileSystemProviderback to summary
public ZipFileSystemProvider()

Method Detail

checkAccessback to summary
public void checkAccess(Path path, AccessMode... modes) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.checkAccess.

Doc from java.nio.file.spi.FileSystemProvider.checkAccess.

Checks the existence, and optionally the accessibility, of a file.

This method may be used by the isReadable, isWritable and isExecutable methods to check the accessibility of a file.

This method checks the existence of a file and that this Java virtual machine has appropriate privileges that would allow it access the file according to all of access modes specified in the modes parameter as follows:

Access Modes
Value Description
READ Checks that the file exists and that the Java virtual machine has permission to read the file.
WRITE Checks that the file exists and that the Java virtual machine has permission to write to the file,
EXECUTE Checks that the file exists and that the Java virtual machine has permission to execute the file. The semantics may differ when checking access to a directory. For example, on UNIX systems, checking for EXECUTE access checks that the Java virtual machine has permission to search the directory in order to access file or subdirectories.

If the modes parameter is of length zero, then the existence of the file is checked.

This method follows symbolic links if the file referenced by this object is a symbolic link. Depending on the implementation, this method may require to read file permissions, access control lists, or other file attributes in order to check the effective access to the file. To determine the effective access to a file may require access to several attributes and so in some implementations this method may not be atomic with respect to other file system operations.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
copyback to summary
public void copy(Path src, Path target, CopyOption... options) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.copy.

Doc from java.nio.file.spi.FileSystemProvider.copy.

Copy a file to a target file. This method works in exactly the manner specified by the Files#copy(Path, Path, CopyOption[]) method except that both the source and target paths must be associated with this provider.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
createDirectoryback to summary
public void createDirectory(Path path, FileAttribute<?>... attrs) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.createDirectory.

Doc from java.nio.file.spi.FileSystemProvider.createDirectory.

Creates a new directory. This method works in exactly the manner specified by the Files#createDirectory method.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs or the parent directory does not exist
deleteback to summary
public final void delete(Path path) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.delete.

Doc from java.nio.file.spi.FileSystemProvider.delete.

Deletes a file. This method works in exactly the manner specified by the Files#delete method.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
ensureFileback to summary
private boolean ensureFile(Path path)
existsback to summary
public boolean exists(Path path, LinkOption... options)

Overrides java.nio.file.spi.FileSystemProvider.exists.

Doc from java.nio.file.spi.FileSystemProvider.exists.

Tests whether a file exists. This method works in exactly the manner specified by the Files#exists(Path, LinkOption...) method.

Annotations
@Override
getFileAttributeViewback to summary
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options)

Implements abstract java.nio.file.spi.FileSystemProvider.getFileAttributeView.

Doc from java.nio.file.spi.FileSystemProvider.getFileAttributeView.

Returns a file attribute view of a given type. This method works in exactly the manner specified by the Files#getFileAttributeView method.

Annotations
@Override
getFileStoreback to summary
public FileStore getFileStore(Path path) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.getFileStore.

Doc from java.nio.file.spi.FileSystemProvider.getFileStore.

Returns the FileStore representing the file store where a file is located. This method works in exactly the manner specified by the Files#getFileStore method.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
getFileSystemback to summary
public FileSystem getFileSystem(URI uri)

Implements abstract java.nio.file.spi.FileSystemProvider.getFileSystem.

Doc from java.nio.file.spi.FileSystemProvider.getFileSystem.

Returns an existing FileSystem created by this provider.

This method returns a reference to a FileSystem that was created by invoking the newFileSystem(URI,Map) method. File systems created by the newFileSystem(Path,Map) method are not returned by this method. The file system is identified by its URI. Its exact form is highly provider dependent. In the case of the default provider the URI's path component is "/" and the authority, query and fragment components are undefined (Undefined components are represented by null).

Once a file system created by this provider is closed it is provider-dependent if this method returns a reference to the closed file system or throws FileSystemNotFoundException. If the provider allows a new file system to be created with the same URI as a file system it previously created then this method throws the exception if invoked after the file system is closed (and before a new instance is created by the newFileSystem method).

Annotations
@Override
getPathback to summary
public Path getPath(URI uri)

Implements abstract java.nio.file.spi.FileSystemProvider.getPath.

Doc from java.nio.file.spi.FileSystemProvider.getPath.

Return a Path object by converting the given URI. The resulting Path is associated with a FileSystem that already exists or is constructed automatically.

The exact form of the URI is file system provider dependent. In the case of the default provider, the URI scheme is "file" and the given URI has a non-empty path component, and undefined query, and fragment components. The resulting Path is associated with the default default FileSystem.

Annotations
@Override
getSchemeback to summary
public String getScheme()

Implements abstract java.nio.file.spi.FileSystemProvider.getScheme.

Doc from java.nio.file.spi.FileSystemProvider.getScheme.

Returns the URI scheme that identifies this provider.

Annotations
@Override
getZipFileSystemback to summary
private ZipFileSystem getZipFileSystem(Path path, Map<String, ?> env) throws IOException
isHiddenback to summary
public boolean isHidden(Path path)

Implements abstract java.nio.file.spi.FileSystemProvider.isHidden.

Doc from java.nio.file.spi.FileSystemProvider.isHidden.

Tells whether or not a file is considered hidden. This method works in exactly the manner specified by the Files#isHidden method.

This method is invoked by the isHidden method.

Annotations
@Override
isSameFileback to summary
public boolean isSameFile(Path path, Path other) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.isSameFile.

Doc from java.nio.file.spi.FileSystemProvider.isSameFile.

Tests if two paths locate the same file. This method works in exactly the manner specified by the Files#isSameFile method.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
moveback to summary
public void move(Path src, Path target, CopyOption... options) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.move.

Doc from java.nio.file.spi.FileSystemProvider.move.

Move or rename a file to a target file. This method works in exactly the manner specified by the Files#move method except that both the source and target paths must be associated with this provider.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
newAsynchronousFileChannelback to summary
public AsynchronousFileChannel newAsynchronousFileChannel(Path path, Set<? extends OpenOption> options, ExecutorService exec, FileAttribute<?>... attrs)

Overrides java.nio.file.spi.FileSystemProvider.newAsynchronousFileChannel.

Doc from java.nio.file.spi.FileSystemProvider.newAsynchronousFileChannel.

Opens or creates a file for reading and/or writing, returning an asynchronous file channel to access the file. This method works in exactly the manner specified by the AsynchronousFileChannel.open method. A provider that does not support all the features required to construct an asynchronous file channel throws UnsupportedOperationException. The default provider is required to support the creation of asynchronous file channels. When not overridden, the default implementation of this method throws UnsupportedOperationException.

Annotations
@Override
newByteChannelback to summary
public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.newByteChannel.

Doc from java.nio.file.spi.FileSystemProvider.newByteChannel.

Opens or creates a file, returning a seekable byte channel to access the file. This method works in exactly the manner specified by the Files#newByteChannel(Path, Set, FileAttribute[]) method.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
newDirectoryStreamback to summary
public DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.newDirectoryStream.

Doc from java.nio.file.spi.FileSystemProvider.newDirectoryStream.

Opens a directory, returning a DirectoryStream to iterate over the entries in the directory. This method works in exactly the manner specified by the Files#newDirectoryStream(java.nio.file.Path, java.nio.file.DirectoryStream.Filter) method.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
newFileChannelback to summary
public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException

Overrides java.nio.file.spi.FileSystemProvider.newFileChannel.

Doc from java.nio.file.spi.FileSystemProvider.newFileChannel.

Opens or creates a file for reading and/or writing, returning a file channel to access the file. This method works in exactly the manner specified by the FileChannel.open method. A provider that does not support all the features required to construct a file channel throws UnsupportedOperationException. The default provider is required to support the creation of file channels. When not overridden, the default implementation throws UnsupportedOperationException.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
newFileSystemback to summary
public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.newFileSystem.

Doc from java.nio.file.spi.FileSystemProvider.newFileSystem.

Constructs a new FileSystem object identified by a URI. This method is invoked by the FileSystems#newFileSystem(URI, Map) method to open a new file system identified by a URI.

The uri parameter is an absolute, hierarchical URI, with a scheme equal (without regard to case) to the scheme supported by this provider. The exact form of the URI is highly provider dependent. The env parameter is a map of provider specific properties to configure the file system.

This method throws FileSystemAlreadyExistsException if the file system already exists because it was previously created by an invocation of this method. Once a file system is closed it is provider-dependent if the provider allows a new file system to be created with the same URI as a file system it previously created.

Annotations
@Override
Exceptions
IOException:
An I/O error occurs creating the file system
newFileSystemback to summary
public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException

Overrides java.nio.file.spi.FileSystemProvider.newFileSystem.

Doc from java.nio.file.spi.FileSystemProvider.newFileSystem.

Constructs a new FileSystem to access the contents of a file as a file system.

This method is intended for specialized providers of pseudo file systems where the contents of one or more files is treated as a file system. The env parameter is a map of provider specific properties to configure the file system.

If this provider does not support the creation of such file systems or if the provider does not recognize the file type of the given file then it throws UnsupportedOperationException. The default implementation of this method throws UnsupportedOperationException.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
newInputStreamback to summary
public InputStream newInputStream(Path path, OpenOption... options) throws IOException

Overrides java.nio.file.spi.FileSystemProvider.newInputStream.

Doc from java.nio.file.spi.FileSystemProvider.newInputStream.

Opens a file, returning an input stream to read from the file. This method works in exactly the manner specified by the Files#newInputStream method.

The default implementation of this method opens a channel to the file as if by invoking the newByteChannel method and constructs a stream that reads bytes from the channel. This method should be overridden where appropriate.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
newOutputStreamback to summary
public OutputStream newOutputStream(Path path, OpenOption... options) throws IOException

Overrides java.nio.file.spi.FileSystemProvider.newOutputStream.

Doc from java.nio.file.spi.FileSystemProvider.newOutputStream.

Opens or creates a file, returning an output stream that may be used to write bytes to the file. This method works in exactly the manner specified by the Files#newOutputStream method.

The default implementation of this method opens a channel to the file as if by invoking the newByteChannel method and constructs a stream that writes bytes to the channel. This method should be overridden where appropriate.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
readAttributesback to summary
public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.readAttributes.

Doc from java.nio.file.spi.FileSystemProvider.readAttributes.

Reads a file's attributes as a bulk operation. This method works in exactly the manner specified by the Files#readAttributes(Path, Class, LinkOption[]) method.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
readAttributesback to summary
public Map<String, Object> readAttributes(Path path, String attributes, LinkOption... options) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.readAttributes.

Doc from java.nio.file.spi.FileSystemProvider.readAttributes.

Reads a set of file attributes as a bulk operation. This method works in exactly the manner specified by the Files#readAttributes(Path, String, LinkOption[]) method.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
readAttributesIfExistsback to summary
public <A extends BasicFileAttributes> A readAttributesIfExists(Path path, Class<A> type, LinkOption... options) throws IOException

Overrides java.nio.file.spi.FileSystemProvider.readAttributesIfExists.

Doc from java.nio.file.spi.FileSystemProvider.readAttributesIfExists.

Reads a file's attributes as a bulk operation if it exists.

The type parameter is the type of the attributes required and this method returns an instance of that type if supported. All implementations support a basic set of file attributes and so invoking this method with a type parameter of BasicFileAttributes.class will not throw UnsupportedOperationException.

The options array may be used to indicate how symbolic links are handled for the case that the file is a symbolic link. By default, symbolic links are followed and the file attribute of the final target of the link is read. If the option NOFOLLOW_LINKS is present then symbolic links are not followed.

It is implementation specific if all file attributes are read as an atomic operation with respect to other file system operations.

Annotations
@Override
@SuppressWarnings:unchecked
Exceptions
IOException:
if an I/O error occurs
removeFileSystemback to summary
pack-priv void removeFileSystem(Path zfpath, ZipFileSystem zfs) throws IOException
setAttributeback to summary
public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException

Implements abstract java.nio.file.spi.FileSystemProvider.setAttribute.

Doc from java.nio.file.spi.FileSystemProvider.setAttribute.

Sets the value of a file attribute. This method works in exactly the manner specified by the Files#setAttribute method.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
toZipPathback to summary
private static ZipPath toZipPath(Path path)
uriToPathback to summary
protected Path uriToPath(URI uri)