Created
May 3, 2013 12:55
-
-
Save korayguclu/5508961 to your computer and use it in GitHub Desktop.
Convert byte to Hex to analyse Encoding problems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String byteToHex(final byte b) { | |
// Returns hex String representation of byte b | |
char hexDigit[] = { | |
'0', '1', '2', '3', '4', '5', '6', '7', | |
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' | |
}; | |
char[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] }; | |
return new String(array); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment