private static String getParentPath(String path) {
      int idx = path.lastIndexOf('/');
      if (idx == path.length() - 1) { // the very last char
        idx = path.lastIndexOf('/', idx - 1);
      }
      if (idx < 0) {
        return "";
      }
      return path.substring(0, idx);
    }
private static String getParentPath(String path)