Generate a hex dump line for debugging. @param buf The byte buffer @param start The starting offset @param len The current message length @return A string representation of the hex dump line
(byte[] buf, int start, int len)
| 398 | * @return A string representation of the hex dump line |
| 399 | */ |
| 400 | protected static String hexLine(byte[] buf, int start, int len) { |
| 401 | StringBuilder sb = new StringBuilder(); |
| 402 | for (int i = start; i < start + 16; i++) { |
| 403 | if (i < len + 4) { |
| 404 | sb.append(hex(buf[i])).append(' '); |
| 405 | } else { |
| 406 | sb.append(" "); |
| 407 | } |
| 408 | } |
| 409 | sb.append(" | "); |
| 410 | for (int i = start; i < start + 16 && i < len + 4; i++) { |
| 411 | if (!Character.isISOControl((char) buf[i])) { |
| 412 | sb.append(Character.valueOf((char) buf[i])); |
| 413 | } else { |
| 414 | sb.append('.'); |
| 415 | } |
| 416 | } |
| 417 | return sb.toString(); |
| 418 | } |
| 419 | |
| 420 | |
| 421 | /** |