Java Parent Path Get getParentPath(String path)

Here you can find the source of getParentPath(String path)

Description

Convenience method to get the Path to the folder containing the file or directory in the supplied path.

License

Open Source License

Parameter

Parameter Description
path a parameter

Return

path to parent

Declaration

public static String getParentPath(String path) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    /**//from   ww w .ja  va 2 s .  c  o  m
     * Convenience method to get the Path to the folder containing
     * the file or directory in the supplied path.
     * @param path
     * @return path to parent
     */
    public static String getParentPath(String path) {
        try {
            return new File(path).getParent();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. getParentPath()
  2. getParentPath(File file, boolean wrap, boolean escape)
  3. getParentPath(String absolutePath)
  4. getParentPath(String filePath)
  5. getParentPath(String fullpath)
  6. getParentPath(String path)
  7. getParentPathAndName(String path, StringBuilder parent)
  8. getParentPathname(String pathname)