static void dumpbin( const void* beg, const void* end
, size_t stride)
{
static const char n2a[]
= { '0', '1', '2', '3', '4', '5', '6', '7'
, '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
const unsigned char* cur = (const unsigned char*)beg;
const size_t len = stride? stride*3 : 3;
char line[len];
char* d = line;
char* const de = d + len -1;
line[len-1] = 0;
while (cur < (unsigned char*)end) {
*d++ = n2a[*cur>>4];
*d++ = n2a[*cur++&0xF];
if (d < de) {
*d++ = ' ';
}
else {
puts(line);
d = line;
}
}
if (d != line) {
*d = 0;
puts(line);
}
}
public static void dumpbin(byte[] b, int stride) {
final String n2a = "0123456789ABCDEF";
StringBuffer sb = new StringBuffer();
int nc = 0;
for (byte c : b) {
sb.append(n2a.charAt((c>>>4)&0xF));
sb.append(n2a.charAt(c&0xF));
if (++nc != stride) {
sb.append(" ");
}
else {
nc = 0;
System.out.println(sb.toString());
sb.setLength(0);
}
}
if (sb.length() > 0) {
System.out.println(sb.toString());
}
}
Uh oh!
There was an error while loading. Please reload this page.