code: public static String getHexdump(final ByteBuffer in) {
          int size = in.remaining();
  
          if (size == 0) {
              return "ByteBufferUtils::getHexdump buffer is empty";
          }
  
          final StringBuilder out = new StringBuilder((in.remaining() * 3) - 1);
  
          final int mark = in.position();
  
          // fill the first
          int byteValue = in.get() & 0xFF;
          out.append((char) highDigits[byteValue]);
          out.append((char) lowDigits[byteValue]);
          size--;
  
          // and the others, too
          for (; size > 0; size--) {
              out.append(' ');
              byteValue = in.get() & 0xFF;
              out.append((char) highDigits[byteValue]);
              out.append((char) lowDigits[byteValue]);
          }
  
          in.position(mark);
  
          return out.toString();
      }
docs: Utility method for dumping a buffer in hex.
  
  @param in
  The buffer to dump.
  @return The hex string.