void doWriteTo(
            final OutputStream out,
            final boolean writeContent) throws IOException {

        final ByteArrayBuffer boundaryEncoded = encode(this.charset, this.boundary);
        if (this.preamble != null) {
            writeBytes(this.preamble, out);
            writeBytes(CR_LF, out);
        }
        for (final MultipartPart part : getParts()) {
            writeBytes(TWO_HYPHENS, out);
            writeBytes(boundaryEncoded, out);
            writeBytes(CR_LF, out);

            formatMultipartHeader(part, out);

            writeBytes(CR_LF, out);

            if (writeContent) {
                part.getBody().writeTo(out);
            }
            writeBytes(CR_LF, out);
        }
        writeBytes(TWO_HYPHENS, out);
        writeBytes(boundaryEncoded, out);
        writeBytes(TWO_HYPHENS, out);
        writeBytes(CR_LF, out);
        if (this.epilogue != null) {
            writeBytes(this.epilogue, out);
            writeBytes(CR_LF, out);
        }
    }
Writes the multipart message to the specified output stream.
<p>
If {@code writeContent} is {@code true}, the content of each part will also be written.

<p>If {@code preamble} is not {@code null}, it will be written before the first boundary.
If {@code epilogue} is not {@code null}, it will be written after the last boundary.

@param out          the output stream to write the message to.
@param writeContent whether to write the content of each part.
@throws IOException if an I/O error occurs.
httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/AbstractMultipartFormat.java