Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java in-memory file structure?

I need to do a lot of things with resources on the fly: parsing xsd/xml docs, building and compiling java classes, package them into jars ans wars, persist in DB, deploy them as OSGi, etc.

Most of the libraries/API's, which I use, allow to perform all these intermediate tasks in memory, but there are some "special" libraries operating with java.io.File only. And there's nothing left for me but using real temporary files and directories which is not good in Java EE environment.

I believe there must be a library/solution for in-memory file structure having nodes extending java.io.File (as I see it). Please drop in a link to known/similar libraries. Any comments are welcome.

Thanks!

like image 656
andbi Avatar asked Jan 24 '11 01:01

andbi


2 Answers

I do not believe you are going to find what you are looking for. The java.io.File API was not written with the intention of providing a file system abstraction that can be implemented in a variety of ways. While it does expose method for some FS operations (such as delete and mkdir), it doesn't handle the basic read/write I/O. That is left to other classes, such as FileInputStream. This means that from API standpoint, a File object is no more than a path. Nothing is abstracted. You are stuck.

like image 175
Konstantin Komissarchik Avatar answered Oct 15 '22 12:10

Konstantin Komissarchik


One option is to use a RAM disk. Your program will think its using the disk with java.io.File, but it will really be using main memory.

like image 35
Jay Avatar answered Oct 15 '22 13:10

Jay