private static String decode(final String str, final int firstPercent) {
    StringBuilder builder = new StringBuilder();
    builder.append(str.substring(0, firstPercent));

    appendDecoded(builder, str, firstPercent);

    for (int i = firstPercent + 3; i < str.length(); ++i) {
      if (str.charAt(i) == '%') {
        appendDecoded(builder, str, i);
        i += 2;
      } else {
        builder.append(str.charAt(i));
      }
    }

    return builder.toString();
  }
Percent-decodes the given string.

@param str the string to decode
@param firstPercent the index of the first '%' character in the string
@return the decoded string
src/main/java/com/creactiviti/piper/taskhandler/s3/AmazonS3URI.java