code: public static String dirpart(final String path) {
          int s = path.lastIndexOf(File.separatorChar);
          if (s != -1) {
              return path.substring(0, s);
          } else {
              return null;
          } 
      }
docs: Returns the directory part of path string.
  @param path Input path
  @return String The directory part of the path