code: public static String trimLastPathSection(String path) {
          String[] sections = path.split("/");
          StringBuilder newPath = new StringBuilder("/");
          for (int i = 1; i < sections.length - 1; i++) {
              newPath.append(sections[i]).append("/");
          }
          return newPath.toString();
      }
docs: Removes the last part of a file path.