/*
* Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006.
*
* Licensed under the Aduna BSD-style license.
*/
public class Utils {
/**
* Returns the hexadecimal value of the supplied byte array. The resulting
* string always uses two hexadecimals per byte. As a result, the length
* of the resulting string is guaranteed to be twice the length of the
* supplied byte array.
*/
public static String toHexString(byte[] array) {
StringBuilder sb = new StringBuilder(2*array.length);
for (int i = 0; i < array.length; i++) {
String hex = Integer.toHexString(array[i] & 0xff);
if (hex.length() == 1) {
sb.append('0');
}
sb.append(hex);
}
return sb.toString();
}
}