• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

jimfs/23-Nov-2023-26,11117,657

util/23-Nov-2023-5535

.gitignoreD23-Nov-202371 139

.travis.ymlD23-Nov-2023902 3222

Android.bpD23-Nov-20231.6 KiB4542

CONTRIBUTING.mdD23-Nov-2023601 1611

LICENSED23-Nov-202311.1 KiB202169

METADATAD23-Nov-2023688 2321

MODULE_LICENSE_APACHE2D23-Nov-20230

README.mdD23-Nov-20233.1 KiB8766

pom.xmlD23-Nov-202311.3 KiB345289

README.md

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