Java Utililty Methods Char Create

List of utility methods to do Char Create

Description

The list of methods to do Char Create are organized into topic(s).

Method

StringtoChar(int i)
0, 1, ..., 51 -> "A", "B", ..., "Z", "AA", "AB", ..., "AZ"
String s = "";
if (i >= 0 && i < 26) {
    s = s + (char) ('A' + i);
} else if (i >= 26 && i < 52) {
    s = "A" + (char) ('A' + i - 26);
return s;
chartoChar(int i)
to Char
if (i >= 0 && i < 26)
    return (char) (i + 'A');
else if (i >= 26 && i < 52)
    return (char) (i + 'a' - 26);
else if (i >= 52 && i < 62)
    return (char) (i + '0' - 52);
else
    throw new IllegalArgumentException("Unsupported char code [" + i + "].");
...
chartoChar(int var)
to Char
return (char) var;
StringtoChar(int[] arr)
to Char
StringBuffer sb = new StringBuffer();
for (int i = 0; i < arr.length; i++) {
    sb.append((char) arr[i]);
return sb.toString();
StringtoChar(int[] arr)
to Char
return toString(arr);
chartoChar(Object obj)
Get the char value of this object, only if the object is an instance of Character
return (obj instanceof Character) ? ((Character) obj).charValue() : '\u0000';
chartoChar(Object value)
to Char
if (null == value) {
    throw new RuntimeException("Impossible to convert " + value + " from "
            + (null == value ? "unknown" : value.getClass().getName()) + " to " + char.class.getName());
if (value instanceof Character) {
    return ((Character) value).charValue();
if (value instanceof Number) {
...
chartoChar(short o)
to Char
return (char) o;
chartoChar(String chars)
to Char
String charsLower = chars.toLowerCase();
char highChar = charsLower.length() > 1 ? charsLower.charAt(0) : '0';
char lowChar = charsLower.length() > 1 ? charsLower.charAt(1) : charsLower.charAt(0);
int byteHigh = Character.isDigit(highChar) ? highChar - '0' : highChar - 'a' + 10;
int byteLow = Character.isDigit(lowChar) ? lowChar - '0' : lowChar - 'a' + 10;
return (char) (((byteHigh << 4) | byteLow) & 0xff);
chartoChar(String delimiter)
to Char
if (delimiter.length() == 1) {
    return delimiter.charAt(0);
} else if (delimiter.toLowerCase().startsWith("0x") && delimiter.length() == 4) {
    return (char) Integer.parseInt(delimiter.substring(2), 16);
} else if (delimiter.toLowerCase().startsWith("\\0") && delimiter.length() == 4) {
    return (char) Integer.parseInt(delimiter.substring(2));
} else if (Character.isDigit(delimiter.charAt(0))) {
    return (char) Integer.valueOf(delimiter).intValue();
...