Jimfs是一个用于Java7+的内存中的文件系统,实现了java.io.file抽象文件系统API.
Mave
<depedecy> <groupId>com.google.jimfs</groupId> <artifactId>jimfs</artifactId> <versio>1.0</versio></depedecy>示例代码:
import com.google.commo.jimfs.Cofiguratio;import com.google.commo.jimfs.Jimfs;...// For a simple file system with Uix-style paths ad behavior:FileSystem fs = Jimfs.ewFileSystem(Cofiguratio.uix());Path foo = fs.getPath("/foo");Files.createDirectory(foo);Path hello = foo.resolve("hello.txt"); // /foo/hello.txtFiles.write(hello, ImmutableList.of("hello world"), StadardCharsets.UTF_8);
评论