The Jimfs library implements an in-memory file system.
You can find other implementations of in-memory file systems if you want to use another library.
The approach is ideal to write unit tests working with files.
You cannot assume to have access to a well-defined file system in a generic continuous integration pipeline.
Unit tests using an in-memory file system can be deployed in a continuous integration pipeline.
When you look at the implementation of Path.of or Paths.get, you will see:
public static Path of(String first, String... more) {
return FileSystems.getDefault().getPath(first, more);
}
So, while this method and similar ones are very convenient, using them will imply you want to access your default file system.
The one your JVM is running on, not your in-memory file system.
Hence, when wanting to make sure your code works against in-memory file systems, you must make sure to never call these helper methods.
Instead, you should always use the FileSystem or a Path instance as an anchor.
Depending on your project and your libraries, this is quite a challenge to pull off
.