Class Jimfs
- java.lang.Object
-
- com.google.common.jimfs.Jimfs
-
public final class Jimfs extends java.lang.ObjectStatic factory methods for creating new Jimfs file systems. File systems may either be created with a basic configuration matching the current operating system or by providing a specificConfiguration. Basic UNIX, Mac OS X and Windows configurations are provided.Examples:
// A file system with a configuration similar to the current OS FileSystem fileSystem = Jimfs.newFileSystem(); // A file system with paths and behavior generally matching that of Windows FileSystem windows = Jimfs.newFileSystem(Configuration.windows());
Additionally, various behavior of the file system can be customized by creating a custom
Configuration. A modified version of one of the existing default configurations can be created usingConfiguration.toBuilder()or a new configuration can be created from scratch withConfiguration.builder(PathType). SeeConfiguration.Builderfor what can be configured.Examples:
// Modify the default UNIX configuration FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix() .toBuilder() .setAttributeViews("basic", "owner", "posix", "unix") .setWorkingDirectory("/home/user") .setBlockSize(4096) .build()); // Create a custom configuration Configuration config = Configuration.builder(PathType.windows()) .setRoots("C:\\", "D:\\", "E:\\") // ... .build();- Author:
- Colin Decker
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringURI_SCHEMEThe URI scheme for the Jimfs file system ("jimfs").
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.nio.file.FileSystemnewFileSystem()Creates a new in-memory file system with a default configuration appropriate to the current operating system.static java.nio.file.FileSystemnewFileSystem(Configuration configuration)Creates a new in-memory file system with the given configuration.static java.nio.file.FileSystemnewFileSystem(java.lang.String name)Creates a new in-memory file system with a default configuration appropriate to the current operating system.static java.nio.file.FileSystemnewFileSystem(java.lang.String name, Configuration configuration)Creates a new in-memory file system with the given configuration.
-
-
-
Field Detail
-
URI_SCHEME
public static final java.lang.String URI_SCHEME
The URI scheme for the Jimfs file system ("jimfs").- See Also:
- Constant Field Values
-
-
Method Detail
-
newFileSystem
public static java.nio.file.FileSystem newFileSystem()
Creates a new in-memory file system with a default configuration appropriate to the current operating system.More specifically, if the operating system is Windows,
Configuration.windows()is used; if the operating system is Mac OS X,Configuration.osX()is used; otherwise,Configuration.unix()is used.
-
newFileSystem
public static java.nio.file.FileSystem newFileSystem(java.lang.String name)
Creates a new in-memory file system with a default configuration appropriate to the current operating system.More specifically, if the operating system is Windows,
Configuration.windows()is used; if the operating system is Mac OS X,Configuration.osX()is used; otherwise,Configuration.unix()is used.The returned file system uses the given name as the host part of its URI and the URIs of paths in the file system. For example, given the name
my-file-system, the file system's URI will bejimfs://my-file-systemand the URI of the path/foo/barwill bejimfs://my-file-system/foo/bar.
-
newFileSystem
public static java.nio.file.FileSystem newFileSystem(Configuration configuration)
Creates a new in-memory file system with the given configuration.
-
newFileSystem
public static java.nio.file.FileSystem newFileSystem(java.lang.String name, Configuration configuration)Creates a new in-memory file system with the given configuration.The returned file system uses the given name as the host part of its URI and the URIs of paths in the file system. For example, given the name
my-file-system, the file system's URI will bejimfs://my-file-systemand the URI of the path/foo/barwill bejimfs://my-file-system/foo/bar.
-
-