Convenience method to convert XML reserved chars.

@param input String to be converted.
@return Converted string.
181712
public static String convertCharsToXml(String input) {
		StringBuffer result = new StringBuffer();
		for(int i=0; i<input.length(); i++) {
			switch(input.charAt(i)) {
				case '<':	result.append("&lt;"); break;
				case '>':	result.append("&gt;"); break;
				case '"':	result.append("&quot;"); break;
				case '\'':	result.append("&apos;"); break;
				case '&':	result.append("&amp;"); break;
				default:	result.append(input.charAt(i));
			}
		}
		return result.toString().trim();
	}
150661
public static String convertToRegexString(final String input) {
        return input.replaceAll("\\\\", "\\\\").replaceAll("\\*", "\\*").replaceAll("\\+", "\\+").replaceAll("\\]", "\\]").replaceAll("\\[",
                "\\[").replaceAll("\\(", "\\(").replaceAll("\\)", "\\)").replaceAll("\\?", "\\?").replaceAll("\\$", "\\$").replaceAll("\\|",
                "\\|").replaceAll("\\^", "\\^").replaceAll("\\.", "\\.");
    }
853994
public static String toSBC(String input, Set<Character> notConvertSet) {
		char c[] = input.toCharArray();
		for (int i = 0; i < c.length; i++) {
			if (null != notConvertSet && notConvertSet.contains(c[i])) {
				// 跳过不替换的字符
				continue;
			}

			if (c[i] == ' ') {
				c[i] = '\u3000';
			} else if (c[i] < '\177') {
				c[i] = (char) (c[i] + 65248);

			}
		}
		return new String(c);
	}
763810
public static String trim(CharSequence input) {
      if (input == null) {
         return null;
      }
      return StringFunctions.TRIM.apply(input.toString());
   }
1272210
@SuppressWarnings("StatementWithEmptyBody")
    public static String encode(final byte[] input) {
        ByteArrayInputStream in = new ByteArrayInputStream(input);
        StringBuilder sb = new StringBuilder();
        try {
            while (encodeChunk(sb, in)) {
                // do nothing
            }
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }

        return sb.toString();
    }
764857
public static String escapeStringForJsRegexp(String input) {
    JsString string = uncheckedCast(input);
    return string.replace(ESCAPE_JS_STRING_REGEXP, "\\$&");
  }
1236853
public static UTF8String concat(UTF8String... inputs) {
    // Compute the total length of the result.
    long totalLength = 0;
    for (int i = 0; i < inputs.length; i++) {
      if (inputs[i] != null) {
        totalLength += (long)inputs[i].numBytes;
      } else {
        return null;
      }
    }

    // Allocate a new byte array, and copy the inputs one by one into it.
    final byte[] result = new byte[Ints.checkedCast(totalLength)];
    int offset = 0;
    for (int i = 0; i < inputs.length; i++) {
      int len = inputs[i].numBytes;
      copyMemory(
        inputs[i].base, inputs[i].offset,
        result, BYTE_ARRAY_OFFSET + offset,
        len);
      offset += len;
    }
    return fromBytes(result);
  }
877807
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();
    }
1287710
private static StringBuilder toStringBuilder(Readable input) throws IOException {
        StringBuilder text = new StringBuilder();
        CharBuffer buffer = CharBuffer.allocate(BUFFER_SIZE);
        while (true) {
            int n = input.read(buffer);
            if (n == -1) {
                break;
            }
            buffer.flip();
            text.append(buffer, 0, n);
        }
        return text;
    }
653214
static public byte[] getBytes(String input) {

        if (null != input) {
            int length = input.length();
            byte[] output = new byte[length];
            for (int i = 0; i < length; i++) {
                output[i] = (byte) input.charAt(i);
            }
            return output;
        }
        return null;
    }
105833
protected static String toLowerCase(String input) {
        if(Character.isUpperCase(input.charAt(0)))
            return input.substring(0, 1).toLowerCase() + input.substring(1);
        return input;
    }
898539
public static String transform(final String inputString) {
        final StringWriter outputWriter = new StringWriter();

        // Transform using the default stylesheet.
        final Source xsltSource = new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream(DEFAULT_XSLT_SHEET));
        XmlUtils.transform(new StreamSource(new StringReader(inputString)), xsltSource, new StreamResult(outputWriter));

        return outputWriter.toString();
    }
346958
public static String escape(String input)
    {
        if (input.isEmpty())
            return input;

        String res = input.replaceAll(":", "\\\\:");
        char last = res.charAt(res.length() - 1);
        return last == '\\' || last == '!' ? res + '!' : res;
    }
537014
public Token[] tokenize(String input) 
    {
    	char[] stringChars =  input.toCharArray();
        List<Token> tokens = new ArrayList<Token>();
        for (char c : stringChars) {
			if(Character.isLetterOrDigit(c)){
				tokens.add(internSomething(Character.toString(c)));
			}
			else if (!ignorePunctuation && !Character.isWhitespace(c)) {
				tokens.add(internSomething(Character.toString(c)));
			}
		}
        return (Token[]) tokens.toArray(new BasicToken[tokens.size()]);
    }
693993
public static String encodeXML( final String    str )
    {
        if ( str == null )
        {
            return null;
        }

        StringCharacterIterator    iterator = new StringCharacterIterator( str );
        StringBuilder              result   = new StringBuilder();
        char                       c;

        for( c  = iterator.current();
             c != CharacterIterator.DONE;
             c  = iterator.next() )
        {
            if ( c == '>' )
            {
                result.append( "&gt;" );
            }
            else if ( c == '<' )
            {
                result.append( "&lt;" );
            }
            else if ( c == '&' )
            {
                result.append( "&amp;" );
            }
            else if ( c == '"' )
            {
                result.append( "&quot;" );
            }
            else if ( c == '\'' )
            {
                result.append( "&#39;" );
            }
            else
            {
                result.append( c );
            }
        }

        return result.toString();
    }
1108434
public static String encode(byte[] input) {
      if (input.length == 0) {
         return "";
      }
      input = copyOfRange(input, 0, input.length);
      // Count leading zeroes.
      int zeroCount = 0;
      while (zeroCount < input.length && input[zeroCount] == 0) {
         ++zeroCount;
      }
      // The actual encoding.
      byte[] temp = new byte[input.length * 2];
      int j = temp.length;

      int startAt = zeroCount;
      while (startAt < input.length) {
         byte mod = divmod58(input, startAt);
         if (input[startAt] == 0) {
            ++startAt;
         }
         temp[--j] = (byte) ALPHABET[mod];
      }

      // Strip extra '1' if there are some after decoding.
      while (j < temp.length && temp[j] == ALPHABET[0]) {
         ++j;
      }
      // Add as many leading '1' as there were leading zeros.
      while (--zeroCount >= 0) {
         temp[--j] = (byte) ALPHABET[0];
      }

      byte[] output = copyOfRange(temp, j, temp.length);
      try {
         return new String(output, "US-ASCII");
      } catch (UnsupportedEncodingException e) {
         throw new RuntimeException(e); // Cannot happen.
      }
   }
100400
public static InputStream toInputStream(String input, String encoding) throws IOException {
        byte[] bytes = input.getBytes(Charsets.toCharset(encoding));
        return new ByteArrayInputStream(bytes);
    }