1*07069803SAndroid Build Coastguard WorkerJimfs 2*07069803SAndroid Build Coastguard Worker===== 3*07069803SAndroid Build Coastguard Worker 4*07069803SAndroid Build Coastguard WorkerJimfs is an in-memory file system for Java 7 and above, implementing the 5*07069803SAndroid Build Coastguard Worker[java.nio.file](http://docs.oracle.com/javase/7/docs/api/java/nio/file/package-summary.html) 6*07069803SAndroid Build Coastguard Workerabstract file system APIs. 7*07069803SAndroid Build Coastguard Worker 8*07069803SAndroid Build Coastguard Worker[](https://travis-ci.org/google/jimfs) 9*07069803SAndroid Build Coastguard Worker[](https://maven-badges.herokuapp.com/maven-central/com.google.jimfs/jimfs) 10*07069803SAndroid Build Coastguard Worker 11*07069803SAndroid Build Coastguard WorkerGetting started 12*07069803SAndroid Build Coastguard Worker--------------- 13*07069803SAndroid Build Coastguard Worker 14*07069803SAndroid Build Coastguard WorkerThe latest release is [1.1](https://github.com/google/jimfs/releases/tag/v1.1). 15*07069803SAndroid Build Coastguard Worker 16*07069803SAndroid Build Coastguard WorkerIt is available in Maven Central as 17*07069803SAndroid Build Coastguard Worker[com.google.jimfs:jimfs:1.1](http://search.maven.org/#artifactdetails%7Ccom.google.jimfs%7Cjimfs%7C1.1%7Cjar): 18*07069803SAndroid Build Coastguard Worker 19*07069803SAndroid Build Coastguard Worker```xml 20*07069803SAndroid Build Coastguard Worker<dependency> 21*07069803SAndroid Build Coastguard Worker <groupId>com.google.jimfs</groupId> 22*07069803SAndroid Build Coastguard Worker <artifactId>jimfs</artifactId> 23*07069803SAndroid Build Coastguard Worker <version>1.1</version> 24*07069803SAndroid Build Coastguard Worker</dependency> 25*07069803SAndroid Build Coastguard Worker``` 26*07069803SAndroid Build Coastguard Worker 27*07069803SAndroid Build Coastguard WorkerBasic use 28*07069803SAndroid Build Coastguard Worker--------- 29*07069803SAndroid Build Coastguard Worker 30*07069803SAndroid Build Coastguard WorkerThe simplest way to use Jimfs is to just get a new `FileSystem` instance from the `Jimfs` class and 31*07069803SAndroid Build Coastguard Workerstart using it: 32*07069803SAndroid Build Coastguard Worker 33*07069803SAndroid Build Coastguard Worker```java 34*07069803SAndroid Build Coastguard Workerimport com.google.common.jimfs.Configuration; 35*07069803SAndroid Build Coastguard Workerimport com.google.common.jimfs.Jimfs; 36*07069803SAndroid Build Coastguard Worker... 37*07069803SAndroid Build Coastguard Worker 38*07069803SAndroid Build Coastguard Worker// For a simple file system with Unix-style paths and behavior: 39*07069803SAndroid Build Coastguard WorkerFileSystem fs = Jimfs.newFileSystem(Configuration.unix()); 40*07069803SAndroid Build Coastguard WorkerPath foo = fs.getPath("/foo"); 41*07069803SAndroid Build Coastguard WorkerFiles.createDirectory(foo); 42*07069803SAndroid Build Coastguard Worker 43*07069803SAndroid Build Coastguard WorkerPath hello = foo.resolve("hello.txt"); // /foo/hello.txt 44*07069803SAndroid Build Coastguard WorkerFiles.write(hello, ImmutableList.of("hello world"), StandardCharsets.UTF_8); 45*07069803SAndroid Build Coastguard Worker``` 46*07069803SAndroid Build Coastguard Worker 47*07069803SAndroid Build Coastguard WorkerWhat's supported? 48*07069803SAndroid Build Coastguard Worker----------------- 49*07069803SAndroid Build Coastguard Worker 50*07069803SAndroid Build Coastguard WorkerJimfs supports almost all the APIs under `java.nio.file`. It supports: 51*07069803SAndroid Build Coastguard Worker 52*07069803SAndroid Build Coastguard Worker- Creating, deleting, moving and copying files and directories. 53*07069803SAndroid Build Coastguard Worker- Reading and writing files with `FileChannel` or `SeekableByteChannel`, `InputStream`, 54*07069803SAndroid Build Coastguard Worker `OutputStream`, etc. 55*07069803SAndroid Build Coastguard Worker- Symbolic links. 56*07069803SAndroid Build Coastguard Worker- Hard links to regular files. 57*07069803SAndroid Build Coastguard Worker- `SecureDirectoryStream`, for operations relative to an _open_ directory. 58*07069803SAndroid Build Coastguard Worker- Glob and regex path filtering with `PathMatcher`. 59*07069803SAndroid Build Coastguard Worker- Watching for changes to a directory with a `WatchService`. 60*07069803SAndroid Build Coastguard Worker- File attributes. Built-in attribute views that can be supported include "basic", "owner", 61*07069803SAndroid Build Coastguard Worker "posix", "unix", "dos", "acl" and "user". Do note, however, that not all attribute views provide 62*07069803SAndroid Build Coastguard Worker _useful_ attributes. For example, while setting and reading POSIX file permissions is possible 63*07069803SAndroid Build Coastguard Worker with the "posix" view, those permissions will not actually affect the behavior of the file system. 64*07069803SAndroid Build Coastguard Worker 65*07069803SAndroid Build Coastguard WorkerJimfs also supports creating file systems that, for example, use Windows-style paths and (to an 66*07069803SAndroid Build Coastguard Workerextent) behavior. In general, however, file system behavior is modeled after UNIX and may not 67*07069803SAndroid Build Coastguard Workerexactly match any particular real file system or platform. 68*07069803SAndroid Build Coastguard Worker 69*07069803SAndroid Build Coastguard WorkerLicense 70*07069803SAndroid Build Coastguard Worker------- 71*07069803SAndroid Build Coastguard Worker 72*07069803SAndroid Build Coastguard Worker``` 73*07069803SAndroid Build Coastguard WorkerCopyright 2013 Google Inc. 74*07069803SAndroid Build Coastguard Worker 75*07069803SAndroid Build Coastguard WorkerLicensed under the Apache License, Version 2.0 (the "License"); 76*07069803SAndroid Build Coastguard Workeryou may not use this file except in compliance with the License. 77*07069803SAndroid Build Coastguard WorkerYou may obtain a copy of the License at 78*07069803SAndroid Build Coastguard Worker 79*07069803SAndroid Build Coastguard Worker http://www.apache.org/licenses/LICENSE-2.0 80*07069803SAndroid Build Coastguard Worker 81*07069803SAndroid Build Coastguard WorkerUnless required by applicable law or agreed to in writing, software 82*07069803SAndroid Build Coastguard Workerdistributed under the License is distributed on an "AS IS" BASIS, 83*07069803SAndroid Build Coastguard WorkerWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 84*07069803SAndroid Build Coastguard WorkerSee the License for the specific language governing permissions and 85*07069803SAndroid Build Coastguard Workerlimitations under the License. 86*07069803SAndroid Build Coastguard Worker``` 87