Class Jimfs
Configuration
. 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 using Configuration.toBuilder()
or a new configuration can be created from
scratch with Configuration.builder(PathType)
. See Configuration.Builder
for 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();
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Logger
(package private) static final @Nullable FileSystemProvider
The system-loaded instance ofSystemJimfsFileSystemProvider
, ornull
if it could not be found or loaded.static final String
The URI scheme for the Jimfs file system ("jimfs"). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static @Nullable FileSystemProvider
Returns the system-loaded instance ofSystemJimfsFileSystemProvider
ornull
if it could not be found or loaded.static FileSystem
Creates a new in-memory file system with a default configuration appropriate to the current operating system.static FileSystem
newFileSystem
(Configuration configuration) Creates a new in-memory file system with the given configuration.static FileSystem
newFileSystem
(String name) Creates a new in-memory file system with a default configuration appropriate to the current operating system.static FileSystem
newFileSystem
(String name, Configuration configuration) Creates a new in-memory file system with the given configuration.(package private) static FileSystem
newFileSystem
(URI uri, Configuration config) private static String
-
Field Details
-
URI_SCHEME
The URI scheme for the Jimfs file system ("jimfs").- See Also:
-
LOGGER
-
systemProvider
The system-loaded instance ofSystemJimfsFileSystemProvider
, ornull
if it could not be found or loaded.
-
-
Constructor Details
-
Jimfs
private Jimfs()
-
-
Method Details
-
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
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-system
and the URI of the path/foo/bar
will bejimfs://my-file-system/foo/bar
. -
newFileSystem
Creates a new in-memory file system with the given configuration. -
newFileSystem
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-system
and the URI of the path/foo/bar
will bejimfs://my-file-system/foo/bar
. -
newFileSystem
-
getSystemJimfsProvider
Returns the system-loaded instance ofSystemJimfsFileSystemProvider
ornull
if it could not be found or loaded.Like
FileSystems.newFileSystem(URI, Map, ClassLoader)
, this method first looks in the list of installed providers and if not found there, attempts to load it from theClassLoader
withServiceLoader
.The idea is that this method should return an instance of the same class (i.e. loaded by the same class loader) as the class whose static cache a
JimfsFileSystem
instance will be placed in whenFileSystems.newFileSystem
is called inJimfs.newFileSystem
. -
newRandomFileSystemName
-