code: private static void writeHex(byte[] bytes, int offset, int dataLength,
        StringBuilder outputBuilder) {
  
      if (bytes == null || bytes.length == 0) {
        return;
      }
  
      char[] hexaValue = new char[16];
      hexaValue[8] = ' ';
  
      int pos = offset;
      int posHexa = 0;
  
      while (pos < dataLength + offset) {
        int byteValue = bytes[pos] & 0xFF;
        outputBuilder.append(hexArray[byteValue >>> 4])
            .append(hexArray[byteValue & 0x0F])
            .append(" ");
  
        hexaValue[posHexa++] = (byteValue > 31 && byteValue < 127) ? (char) byteValue : '.';
  
        if (posHexa == 8) {
          outputBuilder.append(" ");
        }
        if (posHexa == 16) {
          outputBuilder.append("    ")
              .append(hexaValue)
              .append("\n");
          posHexa = 0;
        }
        pos++;
      }
  
      int remaining = posHexa;
      if (remaining > 0) {
        if (remaining < 8) {
          for (; remaining < 8; remaining++) {
            outputBuilder.append("   ");
          }
          outputBuilder.append(" ");
        }
  
        for (; remaining < 16; remaining++) {
          outputBuilder.append("   ");
        }
  
        outputBuilder.append("    ")
            .append(hexaValue, 0, posHexa)
            .append("\n");
      }
    }
docs: Write bytes/hexadecimal value of a byte array to a StringBuilder.
  
  <p>String output example :
  <pre>
  {@code
  38 00 00 00 03 63 72 65  61 74 65 20 74 61 62 6C     8....create tabl
  65 20 42 6C 6F 62 54 65  73 74 63 6C 6F 62 74 65     e BlobTestclobte
  73 74 32 20 28 73 74 72  6D 20 74 65 78 74 29 20     st2 (strm text)
  43 48 41 52 53 45 54 20  75 74 66 38                 CHARSET utf8
  }
  </pre></p>
  
  @param bytes         byte array
  @param offset        offset
  @param dataLength    byte length to write
  @param outputBuilder string builder