Java 8 FileSystem - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 FileSystem class.

This code example shows how to use the following methods:isOpen
    } 
  } 
 
  @Override 
  public boolean isOpen() { 
    return delegate.isOpen();
  } 
 
  @Override 
  public boolean isReadOnly() { 
    return delegate.isReadOnly();
  } 
 
  @Override 
  public String getSeparator() {
    return delegate.getSeparator();
  } 
 
  @Override 
  public Iterable<Path> getRootDirectories() {
5
CodeRank
This code example shows how to use the following methods:close
    return Files.readAllBytes(resolved);
  } 
 
  @Override 
  public void close() throws IOException {
    fs.close();
  } 
} 
5
CodeRank
This code example shows how to use the following methods:provider
   * @param delegateInstance specified base filesystem. 
   */ 
  public FilterFileSystemProvider(String scheme, FileSystem delegateInstance) {
    this.scheme = Objects.requireNonNull(scheme);
    Objects.requireNonNull(delegateInstance);
    this.delegate = delegateInstance.provider();
    this.fileSystem = new FilterFileSystem(this, delegateInstance);
  } 
 
  @Override 
  public String getScheme() {
    return scheme;
  } 
 
  @Override 
  public FileSystem newFileSystem(URI uri, Map<String,?> env) throws IOException {
    return fileSystem;
  } 
   
  @Override 
5
CodeRank
This code example shows how to use the following methods:getPath
  } 
 
  @Test
  public void windows() throws IOException {
    FileSystem fileSystem = this.rule.getFileSystem();
    Path c1 = fileSystem.getPath("C:\\");
    Path c2 = fileSystem.getPath("c:\\");
    assertEquals("C:\\", c1.toString());
    assertEquals(c1.hashCode(), c2.hashCode());
    assertTrue(c1.startsWith(c2));
    assertTrue(c1.startsWith("c:\\"));
    assertEquals(c1, c2);
 
    c1 = fileSystem.getPath("C:\\TEMP");
    c2 = fileSystem.getPath("c:\\temp");
    assertEquals("C:\\TEMP", c1.toString());
    assertTrue(c1.startsWith(c2));
    assertTrue(c1.startsWith("c:\\"));
  } 
 
5
CodeRank
This code example shows how to use the following methods:isReadOnly
        Assert.assertTrue("Provider supplied is of wrong type", provider instanceof ShrinkWrapFileSystemProvider);
    } 
 
    @Test
    public void isReadOnly() { 
        Assert.assertFalse("ShrinkWrap File Systems are not read-only", fileSystem.isReadOnly());
    } 
 
    @Test
    public void isOpen() { 
        Assert.assertTrue("Should report as open", fileSystem.isOpen());
    } 
 
    @Test
    public void isOpenAfterClose() throws IOException {
        fileSystem.close();
        Assert.assertFalse("Should report as closed", fileSystem.isOpen());
    } 
 
    @Test
3
CodeRank
This code example shows how to use the following methods:getPath
  } 
 
  @Test
  public void parse() { 
    FileSystem fileSystem = this.rule.getFileSystem();
    assertEquals(fileSystem.getPath(this.expected), fileSystem.getPath(this.first, this.more));
  } 
 
  @Parameters(name = "first: {0}, more: {1}, expected: {2}") 
  public static List<Object[]> data() {
    return Arrays.asList(new Object[][] {
            { "", null, "" }, 
            { "a", null, "a" }, 
            { "/a", null, "/a" }, 
            { "/a", new String[]{"b", "c"}, "/a/b/c" }, 
            { "/a", new String[]{"/b/", "c"}, "/a/b/c" }, 
            { "/a", new String[]{"/b//", "c"}, "/a/b/c" }, 
            { "/a", new String[]{"//b//", "c"}, "/a/b/c" }, 
            { "/a", new String[]{"//b/", "c"}, "/a/b/c" }, 
            { "/a/", new String[]{"//b/", "c"}, "/a/b/c" }, 
3
CodeRank
This code example shows how to use the following methods:getPathMatcher
        { 
            if (LOG.isDebugEnabled())
            { 
                LOG.debug("Adding exclude: [{}]",syntaxAndPattern);
            } 
            addExclude(dir.getFileSystem().getPathMatcher(syntaxAndPattern));
        } 
 
        /** 
         * Add a <code>glob:</code> syntax pattern exclude reference in a directory relative, os neutral, pattern. 
         * 
         * <pre> 
         *    On Linux: 
         *    Config config = new Config(Path("/home/user/example")); 
         *    config.addExcludeGlobRelative("*.war") =&gt; "glob:/home/user/example/*.war" 
         *  
         *    On Windows 
         *    Config config = new Config(Path("D:/code/examples")); 
         *    config.addExcludeGlobRelative("*.war") =&gt; "glob:D:\\code\\examples\\*.war" 
         * 
3
CodeRank
This code example shows how to use the following methods:getPath
  } 
 
  @Test
  public void contract() throws IOException {
    FileSystem fileSystem = this.rule.getFileSystem();
    Path p = fileSystem.getPath(this.first);
    Path q = fileSystem.getPath(this.second);
    assertEquals(q, p.relativize(p.resolve(q)));
  } 
 
  @Parameters(name = "receiver: {0}, other: {1}") 
  public static List<Object[]> data() {
    return Arrays.asList(new Object[][] {
            { "a", "a" }, 
            { "/a", "a" }, 
            { "a", "a/b" }, 
            { "a/b", "a/b" }, 
            { "/a", "a/b" }, 
            { "/a/b", "a/b" }, 
            { "a", "c" }, 
3
CodeRank
This code example shows how to use the following methods:getPath, isOpen
  @Autowired 
  private FileSystem fileSystem;
 
  @Test
  public void isOpen() { 
    assertTrue(this.fileSystem.isOpen());
    assertEquals("memory:test:///", this.fileSystem.getPath("").toUri().toString());
  } 
 
} 
4
CodeRank
This code example shows how to use the following methods:getPath, getPathMatcher
  } 
 
  @Test
  public void matches() { 
    FileSystem fileSystem = this.rule.getFileSystem();
    Path path = fileSystem.getPath(this.p);
    PathMatcher matcher = fileSystem.getPathMatcher(GlobPathMatcher.name() + ":" + this.pattern);
    assertEquals(this.expected, matcher.matches(path));
  } 
 
  @Parameters(name = "pattern: {0}, path: {1}, should match: {2}") 
  public static List<Object[]> data() {
    return Arrays.asList(new Object[][] {
            { "*.java", "GlobPathMatcherTest.java", true }, 
            { "*.java", "GlobPathMatcherTest.JAVA", true }, 
            { "*.JAVA", "GlobPathMatcherTest.java", true }, 
            { "*.j[a-z]va", "GlobPathMatcherTest.java", true }, 
            { "*.j[A-Z]va", "GlobPathMatcherTest.java", true }, 
            { "*.java", ".java", true }, 
            { "*.java", ".jav.java", true }, 
4
CodeRank
See Code Examples for Java 8 FileSystem Methods: