Skip to content

Instantly share code, notes, and snippets.

@johnzeringue
Last active August 29, 2015 14:14
Show Gist options
  • Save johnzeringue/e2d6c89b698804a06058 to your computer and use it in GitHub Desktop.
Save johnzeringue/e2d6c89b698804a06058 to your computer and use it in GitHub Desktop.
Virtual Filesystems in Java
dependencies {
compile 'com.google.jimfs:jimfs:1.0'
}
import com.google.common.jimfs.Configuration;
import com.google.common.jimfs.Jimfs;
// ...
// create filesystem and get a "virtual path"
FileSystem virtualFileSystem = Jimfs.newFileSystem(Configuration.unix());
Path virtualPath = virtualFileSystem.getPath("virtual", "path");
// use the path as you would any other
Files.exists(virtualPath); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment