code: public static String rtrimWildcardTokens(String input) {
          String[] tokens = tokenizePathAsArray(input);
          StringBuilder sb = new StringBuilder();
          for (int i = 0; i < tokens.length; i++) {
              if (hasWildcards(tokens[i])) {
                  break;
              }
              if (i > 0 && sb.charAt(sb.length() - 1) != File.separatorChar) {
                  sb.append(File.separatorChar);
              }
              sb.append(tokens[i]);
          }
          return sb.toString();
      }
docs: removes from a pattern all tokens to the right containing wildcards
  @param input the input string
  @return the leftmost part of the pattern without wildcards