Java Utililty Methods String to Hex

List of utility methods to do String to Hex

Description

The list of methods to do String to Hex are organized into topic(s).

Method

StringconvertStringToHex(String str)
convert String To Hex
char[] chars = str.toCharArray();
StringBuffer hex = new StringBuffer();
for (int i = 0; i < chars.length; i++) {
    hex.append(Integer.toHexString((int) chars[i]));
return hex.toString();
StringconvertStringToHexComma(String plain, boolean appendNullSigns)
convert String To Hex Comma
if (plain == null || plain.trim().length() == 0)
    return plain;
StringBuffer strBuf = new StringBuffer();
for (int x = 0; x != plain.length(); x++) {
    if (x > 0)
        strBuf.append(",");
    strBuf.append(Integer.toHexString(plain.charAt(x)));
    if (appendNullSigns)
...
StringconvertStringtoHexFormat(String stringToConvert)
This method converts each character in the string to its hexidecimal format
String hexString = "";
for (int index = 0; index < stringToConvert.length(); index++) {
    int x = stringToConvert.charAt(index);
    hexString += "\\u" + Integer.toHexString(x);
return hexString;
StringconvertStringToHexString(String data)
Convert the string to hex string value.
return conventBytesToHexString(data.getBytes());