Shashikanth VH
Committed by Gerrit Code Review

Hex dump read for channel buffer

Change-Id: Ife5e49d488c9806e30530b48bb189f7e4a191e97
......@@ -34,24 +34,21 @@ public final class HexDump {
* @param buff buffer content to dump in hex format
*/
public static void dump(ChannelBuffer buff) {
buff.markReaderIndex();
try {
byte[] yTemp;
yTemp = buff.array();
int iStartIndex = buff.readerIndex();
int iEndIndex = buff.writerIndex();
do {
StringBuilder sb = new StringBuilder();
for (int k = 0; (k < 16) && (iStartIndex < iEndIndex); ++k) {
for (int k = 0; (k < 16) && (buff.readableBytes() != 0); ++k) {
if (0 == k % 4) {
sb.append(String.format(" ")); // blank after 4 bytes
}
sb.append(String.format("%02X ", yTemp[iStartIndex++]));
sb.append(String.format("%02X ", buff.readByte()));
}
log.debug(sb.toString());
} while (iStartIndex < iEndIndex);
} while (buff.readableBytes() != 0);
} catch (Exception e) {
log.error("[HexDump] Invalid buffer: " + e.toString());
}
buff.resetReaderIndex();
}
}
......