Documentation Contents

Developing a Custom File System Provider

Introduction

The NIO.2 API introduced in the Java SE 7 release provides the ability to develop a custom file system provider that can be used to manage file system objects. A file system is essentially a container with organized, homogenous elements referred to as file system objects. A file system provides access to file system objects. A file system object can be a file store, file, or directory. A file store is a volume or partition in which files are stored. For example, in a native file system such as on the Windows platform, commonly known drives like c: or d: are file stores. On the Solaris operating system, / (root) and mounted directories are considered file stores.

The java.nio.file.spi.FileSystemProvider class allows you to develop a custom file system provider. A custom file system provider is useful in the following situations:

Overview of the java.nio.file.spi.FileSystemProvider Class

A custom file system provider must implement the java.nio.file.spi.FileSystemProvider class. A file system provider is identified by a URI scheme such as file, jar, memory, cd.

An implementation of the java.nio.file.spi.FileSystemProvider class is a factory for instances of the java.nio.file.FileSystem class. A file system's URI has a URI scheme that matches the URI scheme of the file system provider that created it.

The newFileSystem method is used to create a file system and the getFileSystem method is used to retrieve a reference to an existing file system.

Implementing a Custom File System Provider

This section describes the high-level steps necessary to create a custom file system provider using the java.nio.file.spi.FileSystemProvider API. The ZipFileSystemProvider class that is shipped in the demo/nio/zipfs of your JDK installation is an example of a custom file system provider. See Resources for information about the zip file system provider.

Implementing the Custom File System Provider Class

Implementing the custom file system provider class involves the following operations:

Implementing the Custom File System Class

Implementing the custom file system class involves the following operations:

Resources


Oracle and/or its affiliates Copyright © 1993, 2020, Oracle and/or its affiliates. All rights reserved.
Contact Us