title: Get FileStore object for any given path
body: <p>Edit: I recognize that FileSystem.getDefault() will give me what I was looking for in my original question statement. I am attempting to use FileSystem.getFileSystem(URI) to get the FileSystem for <strong>any</strong> given path.</p>
  
  <p>I am attempting to develop some code that will give me a java.nio.file.FileSystem object for a given path.</p>
  
  <p>Here is some grossly simplified example code to give a better idea of what is being attempted:</p>
  
  <pre><code>public FileSystem getCwdFilesystem()
  {
      URI cwdUri = null;
      String delimiter = "";
      try
      {
          _cwd = System.getProperty("user.dir");
          cwdUri = new URI("file", delimiter + _cwd, null);
      }
      catch (URISyntaxException ue)
      {
          System.out.println("URI Creation failure on URI: " + _cwd);
          ue.printStackTrace();
          System.exit(1);
      }
  
      System.out.println("Filestore data for CWD: " + cwdUri.toString());
  
      return (FileSystems.getFileSystem(cwdUri));
  }
  </code></pre>
  
  <p>Upon execution, an exception is throw on the last line of code:</p>
  
  <pre><code>Filestore data for CWD: file:/Users/redacted/Documents/Java%20Projects/ExampleCode
  Exception in thread "main" java.lang.IllegalArgumentException: Path component should be '/'
      at sun.nio.fs.UnixFileSystemProvider.checkUri(UnixFileSystemProvider.java:77)
      at sun.nio.fs.UnixFileSystemProvider.getFileSystem(UnixFileSystemProvider.java:92)
      at java.nio.file.FileSystems.getFileSystem(FileSystems.java:217)
      at examplecode.FilesystemCapacity.getCwdFilesystem(FilesystemCapacity.java:54)
      at examplecode.FilesystemCapacity.main(FilesystemCapacity.java:33)
  Java Result: 1
  </code></pre>
  
  <p>When I make a small update to the delimiter variable:</p>
  
  <pre><code>String delimiter = "/";
  </code></pre>
  
  <p>I get a different error message thrown from the same place:</p>
  
  <pre><code>Filestore data for CWD: file://Users/redacted/Documents/Java%20Projects/ExampleCode
  Exception in thread "main" java.lang.IllegalArgumentException: Authority component present
      at sun.nio.fs.UnixFileSystemProvider.checkUri(UnixFileSystemProvider.java:73)
      at sun.nio.fs.UnixFileSystemProvider.getFileSystem(UnixFileSystemProvider.java:92)
      at java.nio.file.FileSystems.getFileSystem(FileSystems.java:217)
      at examplecode.FilesystemCapacity.getCwdFilesystem(FilesystemCapacity.java:54)
      at examplecode.FilesystemCapacity.main(FilesystemCapacity.java:33)
  Java Result: 1
  </code></pre>
  
  <p>Adding additional "/" characters to the delimiter simply gets me the first error message again.</p>
  
  <p>What am I doing wrong?</p>