private static int decodeHexDumpLine(final InputStream inputStream,
                                         final CharsetDecoder charsetDecoder,
                                         final HexDumpBuilder hexDumpBuilder,
                                         final int lineOffset) throws IOException {

        Objects.requireNonNull(inputStream);
        Objects.requireNonNull(charsetDecoder);
        final byte[] lineBytes = new byte[HexDump.MAX_BYTES_PER_LINE];

//        if (!stringBuilder.isEmpty()) {
//            stringBuilder.append("\n");
//        }
        int remaining = HexDump.MAX_BYTES_PER_LINE;
        int len = 0;
        int lineByteCount = 0;
        // Keep reading from the stream till we have a full line of our hex or the
        // stream has ended
        while (remaining > 0 && len >= 0) {
            len = inputStream.read(lineBytes, HexDump.MAX_BYTES_PER_LINE - remaining, remaining);
            if (len > 0) {
                lineByteCount += len;
                remaining -= len;
            }
        }

        // build the hex dump line for these bytes
        appendHexDumpLine(
                hexDumpBuilder,
                lineOffset,
                lineBytes,
                lineByteCount,
                HexDump.MAX_BYTES_PER_LINE,
                charsetDecoder);

        return len;
    }
Produces a hex dump similar to the linux xxd binary.

@param inputStream     The stream to dump as hex
@param charset         The charset to decode single bytes with. Even if a multibyte charset
                       is supplied bytes will only be decoded individually.
@param maxHexDumpLines The max number of line of hex dump output. A full line contains 32 bytes.
@return
@throws IOException
stroom-util/src/main/java/stroom/util/string/HexDumpUtil.java