{@inheritDoc}

@see java.nio.file.spi.FileSystemProvider#getFileSystem(java.net.URI)
168721
@Override
    public FileSystem getFileSystem(final URI uri) {

        // Get open FS
        final FileSystem fs = this.createdFileSystems.get(uri.getHost());

        // If not already created
        if (fs == null) {
            throw new FileSystemNotFoundException("Could not find an open file system with URI: " + uri.toString()
                + "; try creating a new file system?");
        }

        // Return
        return fs;
    }
610946
private static synchronized String getFile(String name) {
        if(Objects.isNullOrEmpty(baseDirectory)){
            baseDirectory = Options.getStorage().getSystem("numberSequence.home", System.getProperty("user.home") + File.separator + ".s1-sequences");
        }
        File dir = new File(baseDirectory);
        if(!dir.exists())
            dir.mkdirs();
        if(!dir.isDirectory())
            throw new S1SystemError("Directory error: "+baseDirectory);
        return dir.getAbsolutePath()+File.separator+name;
    }
598859
private File getFileInRfs(String res) {

        String path = m_destinationPathInRfs + res.substring(0, res.lastIndexOf("/"));
        String fileName = res.substring(res.lastIndexOf("/") + 1);
        return new File(path, fileName);
    }
84656
protected DistributedFileSystem getDFS(Path p) throws IOException {
    FileSystem fs = p.getFileSystem(getConf());
    DistributedFileSystem dfs = null;
    if (fs instanceof DistributedFileSystem) {
      dfs = (DistributedFileSystem) fs;
    } else if (fs instanceof FilterFileSystem) {
      FilterFileSystem ffs = (FilterFileSystem) fs;
      if (ffs.getRawFileSystem() instanceof DistributedFileSystem) {
        dfs = (DistributedFileSystem) ffs.getRawFileSystem();
      }
    }
    return dfs;
  }
367432
@Override
  public String getHomeDirectory() {
    try {
      FileSystem fs = FileSystem.get(CONF);
      return fs.getHomeDirectory().toString();
    }
    catch (Exception e) {
      return null;
    }
  }
1349240
public static Path asPath(URI uri) {
    try {
      return Paths.get(uri);
    } catch (FileSystemNotFoundException e) {
      ClassLoader cl = Thread.currentThread().getContextClassLoader();
      if (cl == null) {
        throw e;
      }
      try {
        return FileSystems.newFileSystem(uri, new HashMap<>(), cl).provider().getPath(uri);
      } catch (IOException ex) {
        throw new RuntimeException("Cannot create filesystem for " + uri, ex);
      }
    }
  }
185217
public File getFile() throws IOException {
        URL url = getURL();
        return GrailsResourceUtils.getFile(url, getDescription());
    }
1001904
public static File getResourceFile(String resourceName) throws URISyntaxException, ClassNotFoundException {
        URL url = ResourceUtil.class.getClassLoader().getResource(resourceName);
        assert url != null : resourceName;
        return new File(url.toURI());
    }
301617
private MIMETypedStream getFromFilesystem(ContentManagerParams params)
            throws HttpServiceNotFoundException,RangeNotSatisfiableException,GeneralException {
        logger.debug("in getFromFilesystem(), url={}", params.getUrl());

        try {
            URL fileUrl = new URL(params.getUrl());
            File cFile = new File(fileUrl.toURI()).getCanonicalFile();
            // security check
            URI cURI = cFile.toURI();
            logger.info("Checking resolution security on {}", cURI);
            Authorization authModule = getServer()
                    .getBean("org.fcrepo.server.security.Authorization", Authorization.class);
            if (authModule == null) {
                throw new GeneralException(
                "Missing required Authorization module");
            }
            String cUriString = cURI.toString();
            authModule.enforceRetrieveFile(params.getContext(), cUriString);
            // end security check
            String mimeType = params.getMimeType();

            // if mimeType was not given, try to determine it automatically
            if (mimeType == null || mimeType.equalsIgnoreCase("")){
                mimeType = determineMimeType(cFile);
            }
            Property [] headers = getFileDatastreamHeaders(cUriString, cFile.lastModified());
            if (ServerUtility.isStaleCache(params.getContext(), headers)) {
                MIMETypedStream result;
                if (isHEADRequest(params)) {
                    result = new MIMETypedStream(mimeType, NullInputStream.NULL_STREAM,
                            headers, cFile.length());
                } else {
                    result = new MIMETypedStream(mimeType, fileUrl.openStream(),
                            headers, cFile.length());
                }
                String rangeHdr =
                        params.getContext().getHeaderValue(HttpHeaders.RANGE);
                if (rangeHdr != null) {
                    result.setRange(rangeHdr);;
                }
                return result;
                
            } else {
                return MIMETypedStream.getNotModified(headers);
            }
        }
        catch(AuthzException ae){
            logger.error(ae.getMessage(),ae);
            throw new HttpServiceNotFoundException("Policy blocked datastream resolution",ae);
        }
        catch (RangeNotSatisfiableException re){
        	logger.error(re.getMessage(), re);
        	throw re;
        }
        catch (GeneralException me) {
            logger.error(me.getMessage(),me);
            throw me;
        } catch (Throwable th) {
            th.printStackTrace(System.err);
            // catch anything but generalexception
            logger.error(th.getMessage(),th);
             throw new HttpServiceNotFoundException("[FileExternalContentManager] "
                    + "returned an error.  The underlying error was a "
                    + th.getClass().getName()
                    + "  The message "
                    + "was  \""
                    + th.getMessage() + "\"  .  ",th);
        }
    }
1172108
public static Uri getFileUri(Context context, File file) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            return FileProvider.getUriForFile(context, context.getPackageName() + ".file.path.share", file);
        }
        return Uri.fromFile(file);
    }
217773
@Nullable
  public static String getFileNameFromUri(URI uri) {
    if (!uri.getScheme().equals("jar")) {
      return uri.getPath();
    }

    try {
      String jarEntryFileName = ((JarURLConnection) uri.toURL().openConnection()).getEntryName();
      // It's possible (though it violates the zip file spec) for paths to zip file entries to use
      // '\' as the separator. Normalize to use '/'.
      jarEntryFileName = BACKSLASH_MATCHER.replaceFrom(jarEntryFileName, '/');
      if (!jarEntryFileName.startsWith("/")) {
        jarEntryFileName = "/" + jarEntryFileName;
      }
      return jarEntryFileName;
    } catch (IOException e) {
      return null;
    }
  }
715313
public static URL getSourceUrl(SourceUnit source) {
        URL url = null;
        final String filename = source.getName();
        if(filename==null) {
            return null;
        }

        Resource resource = new FileSystemResource(filename);
        if (resource.exists()) {
            try {
                url = resource.getURL();
            } catch (IOException e) {
                // ignore
            }
        }
        return url;
    }
511073
private static Path toPath(FileSystem fileSystem, URI uri) {
    // We have to invoke this method by reflection because while the file system should be
    // an instance of JimfsFileSystem, it may be loaded by a different class loader and as
    // such appear to be a totally different class.
    try {
      Method toPath = fileSystem.getClass().getDeclaredMethod("toPath", URI.class);
      return (Path) toPath.invoke(fileSystem, uri);
    } catch (NoSuchMethodException e) {
      throw new IllegalArgumentException("invalid file system: " + fileSystem);
    } catch (InvocationTargetException | IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  }
799593
@NonNull
    public static Uri getUriForFile(@NonNull Context context, @NonNull File file) {
        return getUriForFile(context, Directory.ROOT, file.getPath());
    }
4149
@Override
    public URI getURI() throws IOException {
        URL url = getURL();
        try {
            return ResourceUtils.toURI(url);
        } catch (URISyntaxException ex) {
            throw new RuntimeException("Invalid URI [" + url + "]", ex);
        }
    }
1300008
public static File getFile(NodeList fileNodes) {
    File file = null;
    for (int i = 0; i < fileNodes.getLength(); i++) {
      Element e = (Element) fileNodes.item(i);
      String type = e.getAttribute("type");

      try {
        // URL, File, or Resource
        if (type.equals("url")) {
          URL url = new URL(e.getTextContent());
          file = new File(url.toURI());
        } else if (type.equals("file")) {
          file = new File(e.getTextContent());
        } else if (type.equals("resource")) {
          ClassLoader cl = Thread.currentThread()
                  .getContextClassLoader();
          file = new File(cl.getResource(e.getTextContent())
                  .getFile());
        } else {
          System.out
                  .println("Incorrect file reference:  Unknown type!");
        }
      } catch (Exception exception) {
        System.err.println("Error getting file. "
                + exception.getMessage());
        jlogger.log( SEVERE,
                "Error getting file. " + exception.getMessage(), e);

        return null;
      }
    }
    return file;
  }
536225
public static URI convertUriWithoutSchemeToFileScheme(URI uri) {
        if (uri.getScheme() == null) {
            return Paths.get(uri.getPath()).toUri();
        }
        return uri;
    }