Tuesday, November 29, 2011

Converting a byte array into Hexadecimal String in Java

I have written a method named byteArrayToHexString() which takes a byte array as parameter, and returns the Hexadecimal representation of the byte array. Below is the method.


public static String byteArrayToHexString(byte []input){
String string = "";
if(input == null){
return string;
}

for(byte b : input){
string += Integer.toHexString(Integer.parseInt(Byte.toString(b))).toUpperCase();
}

return string;
}

No comments:

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...