Questions tagged [jimfs]

An in-memory file system for Java 7+

Jimfs in an in-memory file system for Java 7+, implementing the java.nio.file abstract file system APIs.

23 questions
13
votes
1 answer

JimFS: how to get File from Path

I started using google jimfs and I can't understand how I can get file from path. In source code I see that Path.toFile throws UnsupportedOperationException. But how then can I use it without files? For example if my application need to know if some…
Pavel_K
  • 10,748
  • 13
  • 73
  • 186
8
votes
1 answer

Set DefaultFileSystemProvider for testing

How can I set the DefaultFileSystemProvider to use, for example, JimfsFileSystemProvider? The javadoc for FileSystems.getDefault() says I need to set a system property, but when I try to do that I get a…
S1lentSt0rm
  • 1,989
  • 2
  • 17
  • 28
6
votes
4 answers

creating a virtual file system with JIMFS

I'd like to use Google's JIMFS for creating a virtual file system for testing purposes. I have trouble getting started, though. I looked at this tutorial: http://www.hascode.com/2015/03/creating-in-memory-file-systems-with-googles-jimfs/ However,…
user3629892
  • 2,960
  • 9
  • 33
  • 64
5
votes
2 answers

Clone git repository in-memory

I've been trying to clone a tiny git configuration repository into memory using JGIT and JIMFS using something like FileSystem fs = Jimfs.newFileSystem(Configuration.unix()); Path gitPath = Files.createDirectories(fs.getPath("/git"));…
Malt
  • 28,965
  • 9
  • 65
  • 105
5
votes
2 answers

Set last modified timestamp of a file using jimfs in Java

How can I set a last modified date of a file using jimfs? I have smth. like this: final FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix()); Path rootPath = Files.createDirectories(fileSystem.getPath("root/path/to/directory")); Path…
Arthur Eirich
  • 3,368
  • 9
  • 31
  • 63
5
votes
1 answer

JimFS: what is the purpose of /work directory

I started to use google jimfs and doing ls I found there work directory in the root of FS. What is the purpose of this folder?
Pavel_K
  • 10,748
  • 13
  • 73
  • 186
5
votes
1 answer

How to force an IOException in jimfs

I have file related code to test where I would like to test my error handling for an existing file that I cannot read. class SomeClass { //... public void load(Path path) { if (!Files.isRegularFile(path)) { return null; …
EdJoJob
  • 1,139
  • 9
  • 15
4
votes
0 answers

java git-library with configurable in-memory FileSystem

Is there a java-library that operates on a user-provided java.nio.file.FileSystem ? I'm using googles jimfs in-memory-filesystem implementation and would like to clone a git repository into my filesystem and perform a complex series of operations…
Gaetano
  • 1,090
  • 1
  • 9
  • 25
4
votes
0 answers

Changing the JVM's default file system

I have an application that I am trying to run in an in-memory file system but my application has a dependency that uses java.io as opposed to java.nio. Is there any way I can change the JVM's default file system to remedy this?
Michael Chav
  • 441
  • 5
  • 15
4
votes
1 answer

JIMFS not recognized by ZipFileSystemProvider

I have a zip file created in jimfs (google in memory file system) from a byte array. When trying to open that file with ZipMemoryFileSystem, I get an error that the provider is not recognized. My code is as following: public static void…
Caroh
  • 113
  • 8
3
votes
3 answers

Provider not found exception when creating a FileSystem for my zip?

I have created a Zip file on a JimFS FileSystem instance. I would now like to read the Zip using the Java FileSystem API. Here is how I create the FileSystem: final FileSystem zipFs = FileSystems.newFileSystem( source, // source is a Path tied…
sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
3
votes
2 answers

Java: ZipFile using Path

I have a Path to zip file on virtual filesystem (jimfs) and I need to open this zip file using ZipFile. But there is no constructor in ZipFile to get Path as argument, only File. However, I can't create from my Path a File (path.toFile()) because I…
Pavel_K
  • 10,748
  • 13
  • 73
  • 186
3
votes
1 answer

JIMFS for production in memory filesystem

I have a specific use case where it would benefit me to abstract a normal filesystem into an in memory one since we often switch between the two for performance reasons. Can JIMFS be used in a production environment or is it purely made for…
2
votes
1 answer

Testing file system interaction: Setting file permissions

I stumbled upon Jimfs and wanted to use it for testing methods with file system interaction. For example, I wrote a pretty long method that figures out, if writing to a list of files could succeed: static boolean exportable(List paths, boolean…
S1lentSt0rm
  • 1,989
  • 2
  • 17
  • 28
1
vote
2 answers

java attach file from virtual filesystem to email

I am using a virtual filesystem and I'd like to attach a file from it to an email. However, the MimeBodyPart object only takes Files, which don't work on a default filesystem like jimfs. See my code below, where I get an UnsupportedOperation…
Steve
  • 4,457
  • 12
  • 48
  • 89
1
2