Code with Finding: |
class Hex {
/**
* Converts part of a byte array to capitalized hexadecimal text.
* Conversion starts at index <code>offset</code> until (excluding)
* index <code>offset + length</code>.
* The length of the resulting string will be twice the length
* <code>text</code> and will only contain the characters '0', '1',
* '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'.
*
* @param text the byte array to convert.
* @param offset where to start.
* @param length how many bytes to convert.
*
* @return capitalized hexadecimal text representation of
* <code>text</code>.
*/
public static String bytesToHexString(byte[] text, int offset, int length) {
String result = "";
for (int i = 0; i < length; i++) {
result += byteToHexString(text[offset + i]);
}
return result;
}
}
|