code: static public String getHexDump(byte[] data, int length) {
          // boundary checks....
          if (null == data || 0 > length) {
              return null;
          }
          // if we have less than the target amount, just print what we have
          if (data.length < length) {
              length = data.length;
          }
          int numlines = (length / 16) + (((length % 16) > 0) ? 1 : 0);
          StringBuilder buffer = new StringBuilder(73 * numlines);
          for (int i = 0, line = 0; line < numlines; line++, i += 16) {
              buffer = formatLineId(buffer, i);
              buffer.append(": ");
              // format the first 8 bytes as hex data
              buffer = formatHexData(buffer, data, i);
              buffer.append("  ");
              // format the second 8 bytes as hex data
              buffer = formatHexData(buffer, data, i + 8);
              buffer.append("  ");
              // now print the ascii version, filtering out non-ascii chars
              buffer = formatTextData(buffer, data, i);
              buffer.append('\n');
          }
          return buffer.toString();
      }
docs: Debug print the input byte[] up to the input maximum length. This will be
  a sequence of 16 byte lines, starting with a line indicator, the hex
  bytes and then the ASCII representation.
  
  @param data
  @param length
  @return String