public static String unescapePathName(String path) {
    int firstUnescapeIndex = path.indexOf('%');
    if (firstUnescapeIndex == -1) {
      return path;
    }

    StringBuilder sb = new StringBuilder();
    if (firstUnescapeIndex > 0) {
      sb.append(path, 0, firstUnescapeIndex);
    }

    for (int i = firstUnescapeIndex; i < path.length(); i++) {
      char c = path.charAt(i);
      if (c == '%' && i + 2 < path.length()) {
        int code = -1;
        try {
          code = Integer.parseInt(path.substring(i + 1, i + 3), 16);
        } catch (Exception e) {
          code = -1;
        }
        if (code >= 0) {
          sb.append((char) code);
          i += 2;
          continue;
        }
      }
      sb.append(c);
    }
    return sb.toString();
  }
Escapes a path name.
@param path The path to escape.
@param defaultPath
         The default name for the path, if the given path is empty or null.
@return An escaped path name.
common/src/java/org/apache/hadoop/hive/common/FileUtils.java