9

I was looking for in-memory nio2 FileSystem implementations, that would allow me to more easily test my IO-dependent code.

It seems natively, Java only provides (in my JDK) a Win32FileSystem and a ZipFileSystem.

It seems ShrinkWrap has something of the kind, but seems to mainly deal with ZIP File Systems or whatsoever.

I'd guess by the time being, some of you are already incorporating the new nio FileSystem IO in your own projects and could help me with this?

Thanks

devoured elysium
  • 101,373
  • 131
  • 340
  • 557
  • can't you use mocks? plz provide some code example that requires filesystem to test – piotrek Oct 21 '12 at 00:33
  • ShrinkWrap seems to have a blog post advertising an in memory fs ( http://exitcondition.alrubinger.com/2012/08/17/shrinkwrap-nio2/ ) however it doesn't seem to work correct :( (Files.isDirectory() returns false for directories) – Patrick Huy Apr 09 '13 at 12:46

4 Answers4

9

https://github.com/google/jimfs provides this functionality. I never tested it myself.

wischan
  • 3,740
  • 1
  • 18
  • 14
1

You can try https://github.com/marschall/memoryfilesystem. Should be a perfect fit for your needs.

dwegener
  • 482
  • 5
  • 15
0

ShrinkWrap does indeed have an NIO.2 in-memory filesystem implementation, and the directory reporting as "false" issue noted by Patrick has been fixed (by him. :) ): https://github.com/shrinkwrap/shrinkwrap/commit/3319e64c455a5f0e601b19066318d28c4bea3df1

S, ALR

ALRubinger
  • 31
  • 3
0

https://github.com/openCage/memoryfs is such an in-memory filesystem. It implements most but not yet all of the nio2 API.

Note: I am the author. Let me know if you find a bug or need a feature.

openCage
  • 2,735
  • 1
  • 18
  • 24
  • Thanks for you efforts! How does it compare to google/jimfs and marschall/memoryfilesystem? – Puce Mar 04 '15 at 16:27