Here you can find the source of printTraceHexData(PrintWriter trc, ByteBuffer buf, int startPos, int endPos)
static void printTraceHexData(PrintWriter trc, ByteBuffer buf, int startPos, int endPos)
//package com.java2s; /******************************************************************************* * The MIT License (MIT)// w ww . j a v a 2 s .c o m * Copyright (c) 2015 Frank Benoit, Stuttgart, Germany <keinfarbton@gmail.com> * * See the LICENSE.md or the online documentation: * https://docs.google.com/document/d/1Wqa8rDi0QYcqcf0oecD8GW53nMVXj3ZFSmcF81zAa8g/edit#heading=h.2kvlhpr5zi2u * * Contributors: * Frank Benoit - initial API and implementation *******************************************************************************/ import java.io.PrintWriter; import java.nio.ByteBuffer; public class Main { static void printTraceHexData(PrintWriter trc, ByteBuffer buf, int startPos, int endPos) { int len = endPos - startPos; for (int i = 0; i < len; i += 16) { trc.printf(" "); for (int k = 0; k + i < len && k < 16; k++) { if (k > 0) { trc.print(" "); if (k % 4 == 0) { trc.print(" "); } } trc.printf("%02X", 0xFF & buf.get(i + k)); } trc.printf("%n"); } trc.printf(" <<%n%n"); } }