code: public static String getParentPath(final String path) {
      final int pos = path.lastIndexOf(File.separator);
      if (pos <= 0) {
        return null;
      }
      return path.substring(0, pos);
    }
docs: Extracts the parent of a file