Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > Core Java Code Examples

Converting Non ASCII String to Hex

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Converting Non ASCII String to Hex public static String toHexString(char c) { String rep; String temp; int low = c & 0x00FF; int high = c & 0xFF00; temp = Integer.toHexString(low); if( temp.length() == 1 ) temp = "0" + temp; rep = temp; temp = Integer.toHexString(high); if( temp.length() == 1 ) temp = "0" + temp; rep += temp; // If you want a space between bytes // rep += " " + temp; return rep; } public static void main(String a[]) { String str = toHexString('b'); System.out.println(str); }