| Code with Finding: |
class Hex {
/**
* Hexadecimal representations of <code>data</code> with spaces between
* individual bytes. Each string represents <code>columns</code> bytes,
* except for the last one, which represents at most <code>columns</code>
* bytes.
*
* @param data the byte array to represent.
* @param columns the width of each line.
* @param padWidth resulting strings will be padded to this length with
* spaces to the right.
*
* @return spaced hexadecimal representations of <code>data</code>.
*/
private static String[] bytesToSpacedHexStrings(byte[] data, int columns,
int padWidth) {
byte[][] src = split(data,columns);
String[] result = new String[src.length];
for (int j = 0; j < src.length; j++) {
result[j] = bytesToSpacedHexString(src[j]);
result[j] = pad(result[j],padWidth,' ',RIGHT);
}
return result;
}
}
|