//Duplicate so we don't destroy original data :)
ByteBuffer hexBuffer = chunk.getData().duplicate();
ByteBuffer charBuffer = hexBuffer.duplicate();
Hex hexencoder = new Hex();
while (hexBuffer.hasRemaining())
{
byte[] line = new byte[LINE_SIZE];
int bufsize = hexBuffer.remaining();
if (bufsize < LINE_SIZE)
{
hexBuffer.get(line, 0, bufsize);
}
else
{
bufsize = line.length;
hexBuffer.get(line);
}
byte[] encoded = hexencoder.encode(line);
try
{
String encStr = new String(encoded, 0, bufsize * 2, DEFAULT_ENCODING);
String hexLine = "";