public StringBuilder getStringBuilder(Charset charset) {
            final byte[] entity = byteArrayOutputStream.toByteArray();

            stringBuilder.append(new String(entity, 0, Math.min(entity.length, maxEntitySize), charset));
            if (entity.length > maxEntitySize) {
                stringBuilder.append("...[truncated]");
            }
            stringBuilder.append('\n');

            return stringBuilder;
        }
Write the contents of a request/response body, up to a certain length
stroom-util/src/main/java/stroom/util/logging/DefaultLoggingFilter.java