I want to create a simple in-memory file system in Java that has one root directory and can create a new subdirectory. In the directory we can create new files, write to them, read from them, delete them and also rename them. Can you give some tips on where to start (simple code or resouce).
The custom file system provider must implement the java.nio.file.spi.FileSystemProvider class. The file system provider is identified by a URI scheme such as file, jar, memory, cd.
Below are the links below.
http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/filesystemprovider.html
The link below (and not on the file system) refers to the virtual file system. It talks about some design issues that can help you if you decide to create your own file system.
http://www.flipcode.com/archives/Programming_a_Virtual_File_System-Part_I.shtml
But you can always use already built and tested code. It will be faster and easier to maintain, and you will receive support in the face of errors.
Take a look at jimfs (in-memory file system for Java 7+)
https://github.com/google/jimfs
Also view
Commons Virtual File System http://commons.apache.org/proper/commons-vfs/
marschall (An in memory for implementing the JSR-203 file system) https://github.com/marschall/memoryfilesystem
You can create an In-memory file system in java using the Googles Jimfs and java 7 NIO packages.
Please refer to this link. Here you will get a sample tutorial: create a file system in memory in java
Use memoryfilesystem .
Jimfs is mentioned in a previous answer, but the memoryfilesystem handles a lot more.
Usage example:
final FileSystem fs = MemoryFileSystem.newLinux().build("myfs"); final Path dir = fs.getPath("thedir"); Files.createDirectory(dir);
etc. Use the java.nio.file API to manage the files in this ( File will not work!). See here for more details.
File
Source: https://habr.com/ru/post/987733/More articles:RxJS - Catch and Continue - javascriptMailjet: adding email to the list does not work - phpThe method to call Nsubstitute when there is a DoNotCallBase - c #Invariant culture equivalent TryParse Convert - c #Unable to install git2r or devtools R packages on CentOS 7.0 64 bit - rIn C ++, which is better than i> -1 or i> = 0 - c ++Java getDate 0000/00/00 returns a strange value - javaLaravel blade template special code - phpRuby on Rails 4 - import CSV - implicit conversion to string - ruby | fooobar.comDynamically building a zoo cluster - apache-zookeeperAll Articles