use of org.neo4j.kernel.impl.util.HexPrinter in project neo4j by neo4j.
the class Client method beginningOfBufferAsHexString.
protected static String beginningOfBufferAsHexString(ChannelBuffer buffer, int maxBytesToPrint) {
// read buffer from pos 0 - writeIndex
int prevIndex = buffer.readerIndex();
buffer.readerIndex(0);
try {
ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(buffer.readableBytes());
PrintStream stream = new PrintStream(byteArrayStream);
HexPrinter printer = new HexPrinter(stream).withLineNumberDigits(4);
for (int i = 0; buffer.readable() && i < maxBytesToPrint; i++) {
printer.append(buffer.readByte());
}
stream.flush();
return byteArrayStream.toString();
} finally {
buffer.readerIndex(prevIndex);
}
}
Aggregations