Returns the directory of the file.

@param filePath Path of the file.
@return The directory string or {@code null} if
there is no parent directory.
@throws IllegalArgumentException if path is bad
421338
public static String getParentDirectory(String filePath) throws IllegalArgumentException {
        if (Pattern.matches(sPatternUrl, filePath))
            return getURLParentDirectory(filePath);

        return new File(filePath).getParent();
    }
31553
public static File getClasspathFile(String filename) {
    if(filename == null) {
      throw LOG.nullParameter("filename");
    }

    return getClasspathFile(filename, null);
  }
1105399
private File getFileFromPath(final String path) {
        File result = (path != null) ? new File(path) : null;
        // AS7-1752 see if a non-existent relative path exists relative to the home dir
        if (result != null && homeDir != null && !result.exists() && !result.isAbsolute()) {
            File relative = new File(homeDir, path);
            if (relative.exists()) {
                result = relative;
            }
        }
        return result;
    }
483324
@Override
    public FileStore getFileStore(final Path path) throws IOException {
        final FileStore fileStore = path.getFileSystem().getFileStores().iterator().next();
        return fileStore;
    }
533477
public static FileInputStream getFileInputStream(String filePath) throws Exception {
        FileInputStream localFileInputStream = new FileInputStream(filePath);
        return localFileInputStream;
    }
1304832
protected String getRelativePath(String ancestor, String rootPath) {

        String result = rootPath.substring(ancestor.length());
        result = CmsStringUtil.joinPaths("/", result, "/");
        return result;
    }
733697
public static String getCategoryPath(String rootPath, String baseFolder) throws Exception {

        String base;
        if (rootPath.startsWith(CmsCategoryService.CENTRALIZED_REPOSITORY)) {
            base = CmsCategoryService.CENTRALIZED_REPOSITORY;
        } else {
            base = baseFolder;
            if (!base.endsWith("/")) {
                base += "/";
            }
            if (!base.startsWith("/")) {
                base = "/" + base;
            }
            int pos = rootPath.indexOf(base);
            if (pos < 0) {
                throw new Exception("Invalid category location \"" + rootPath + "\".");
            }
            base = rootPath.substring(0, pos + base.length());
        }
        return rootPath.substring(base.length());
    }
930352
public static String getCategoryPath(String rootPath, String baseFolder) throws CmsException {

        String base;
        if (rootPath.startsWith(CmsCategoryService.CENTRALIZED_REPOSITORY)) {
            base = CmsCategoryService.CENTRALIZED_REPOSITORY;
        } else {
            base = baseFolder;
            if (!base.endsWith("/")) {
                base += "/";
            }
            if (!base.startsWith("/")) {
                base = "/" + base;
            }
            int pos = rootPath.indexOf(base);
            if (pos < 0) {
                throw new CmsDataAccessException(
                    Messages.get().container(Messages.ERR_CATEGORY_INVALID_LOCATION_1, rootPath));
            }
            base = rootPath.substring(0, pos + base.length());
        }
        return rootPath.substring(base.length());
    }
1197383
@Override
    public Path getParent() {
        final List<String> tokens = tokenize(this);
        // No parent?
        final int numTokens = tokens.size();
        if (numTokens == 0 || (numTokens == 1 && !this.isAbsolute())) {
            return null;
        }

        // Iterate over all but the last token and build a new path
        final StringBuffer sb = new StringBuffer();
        if (this.isAbsolute()) {
            sb.append(ArchivePath.SEPARATOR);
        }
        for (int i = 0; i < numTokens - 1; i++) {
            if (i >= 1) {
                sb.append(ArchivePath.SEPARATOR);
            }
            sb.append(tokens.get(i));
        }

        final String parentPath = sb.toString();
        return new ShrinkWrapPath(parentPath, fileSystem);
    }
56128
public static String getRelativePath(File file, File folder) {

        String filePath = file.getAbsolutePath();
        String folderPath = folder.getAbsolutePath();

        if (filePath.startsWith(folderPath)) {
            return filePath.substring(folderPath.length() + 1);
        } else {
            return null;
        }
    }
86350
@Override
    Resource getResource(final String relativePath) {
        final File resourceFile = new File(classpathEltDir, relativePath);
        return resourceFile.canRead() && resourceFile.isFile() ? newResource(relativePath, resourceFile) : null;
    }
26621
public static Optional<String> getStringAsOptWithFilePath(
            String filePath, String charsetName) {
        return JMOptional
                .getOptional(JMFiles.readString(filePath, charsetName));
    }
37681
public function getParentDirectory(): ?FilePathInterface
    {
        if ($this->myParentDirectory($aboveBaseLevel, $directoryParts)) {
            return new self($this->myIsAbsolute, $aboveBaseLevel, $this->myDrive, $directoryParts, null);
        }

        return null;
    }
154880
public @CheckForNull FilePath getWorkspaceRoot() {
        FilePath r = getRootPath();
        if(r==null) return null;
        return r.child(WORKSPACE_ROOT);
    }
892292
public static short getLocalFileMode(String filePath) throws IOException {
    Set<PosixFilePermission> permission =
        Files.readAttributes(Paths.get(filePath), PosixFileAttributes.class).permissions();
    return translatePosixPermissionToMode(permission);
  }
259199
public static OutputStream toFile(String filepath) throws FileNotFoundException {
		if(Strings.isValid(filepath)) {
			return new FileOutputStream(new File(filepath));
		}
		return null;
	}
1251161
private boolean validateFilePath(String filePath) {
        if (filePath == null || filePath.isEmpty()) {
            throw new IllegalArgumentException("filePath must be a valid filePath within the file system.");
        }

        // Check if the filename exists as a File -- use an absolute file to ensure we have
        // a parent: even if that parent is ${user.dir} ...
        File loc = new File(filePath).getAbsoluteFile();

        return (loc.exists() || loc.getParentFile().exists());
    }