com.sun.xml.internal.messaging.saaj.packaging.mime.util.OutputUtil Java Examples

The following examples show how to use com.sun.xml.internal.messaging.saaj.packaging.mime.util.OutputUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MimeMultipart.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Iterates through all the parts and outputs each Mime part
 * separated by a boundary.
 *
 * @param os output stream.
 *
 * @exception IOException if an I/O Error occurs.
 * @exception MessagingException in case of error.
 */
public void writeTo(OutputStream os)
        throws IOException, MessagingException {
    parse();

    String boundary = "--" + contentType.getParameter("boundary");

    for (int i = 0; i < parts.size(); i++) {
        OutputUtil.writeln(boundary, os); // put out boundary
        getBodyPart(i).writeTo(os);
        OutputUtil.writeln(os); // put out empty line
    }

    // put out last boundary
    OutputUtil.writeAsAscii(boundary, os);
    OutputUtil.writeAsAscii("--", os);
    os.flush();
}