Package com.google.code.com.sun.mail.util

Examples of com.google.code.com.sun.mail.util.LineOutputStream


        throws IOException, MessagingException {
  parse();
 
  String boundary = "--" +
    (new ContentType(contentType)).getParameter("boundary");
  LineOutputStream los = new LineOutputStream(os);

  // if there's a preamble, write it out
  if (preamble != null) {
      byte[] pb = ASCIIUtility.getBytes(preamble);
      los.write(pb);
      // make sure it ends with a newline
      if (pb.length > 0 &&
        !(pb[pb.length-1] == '\r' || pb[pb.length-1] == '\n')) {
    los.writeln();
      }
      // XXX - could force a blank line before start boundary
  }

  if (parts.size() == 0) {
      // have to read the property every time because parse won't
      // read it if the message was *not* constructed from a stream.
      // default to false
      allowEmpty = PropUtil.getBooleanSystemProperty(
    "mail.mime.multipart.allowempty", false);
      if (allowEmpty) {
    // write out a single empty body part
    los.writeln(boundary); // put out boundary
    los.writeln(); // put out empty line
      } else {
    throw new MessagingException("Empty multipart: " + contentType);
      }
  } else {
      for (int i = 0; i < parts.size(); i++) {
    los.writeln(boundary); // put out boundary
    ((MimeBodyPart)parts.elementAt(i)).writeTo(os);
    los.writeln(); // put out empty line
      }
  }

  // put out last boundary
  los.writeln(boundary + "--");
    }
View Full Code Here


     */
    public void writeTo(OutputStream os)
      throws IOException, MessagingException {

  // see if we already have a LOS
  LineOutputStream los = null;
  if (os instanceof LineOutputStream) {
      los = (LineOutputStream) os;
  } else {
      los = new LineOutputStream(os);
  }

  // First, write out the header
  Enumeration hdrLines = getAllHeaderLines();
  while (hdrLines.hasMoreElements())
      los.writeln((String)hdrLines.nextElement());

  // The CRLF separator between header and content
  los.writeln();

  // Finally, the content, already encoded.
  getDataHandler().writeTo(os);
  os.flush();
    }
View Full Code Here

        throws IOException, MessagingException {
  parse();
 
  String boundary = "--" +
    (new ContentType(contentType)).getParameter("boundary");
  LineOutputStream los = new LineOutputStream(os);

  // if there's a preamble, write it out
  if (preamble != null) {
      byte[] pb = ASCIIUtility.getBytes(preamble);
      los.write(pb);
      // make sure it ends with a newline
      if (pb.length > 0 &&
        !(pb[pb.length-1] == '\r' || pb[pb.length-1] == '\n')) {
    los.writeln();
      }
      // XXX - could force a blank line before start boundary
  }

  if (parts.size() == 0) {
      // have to read the property every time because parse won't
      // read it if the message was *not* constructed from a stream.
      // default to false
      allowEmpty = PropUtil.getBooleanSystemProperty(
    "mail.mime.multipart.allowempty", false);
      if (allowEmpty) {
    // write out a single empty body part
    los.writeln(boundary); // put out boundary
    los.writeln(); // put out empty line
      } else {
    throw new MessagingException("Empty multipart: " + contentType);
      }
  } else {
      for (int i = 0; i < parts.size(); i++) {
    los.writeln(boundary); // put out boundary
    ((MimeBodyPart)parts.elementAt(i)).writeTo(os);
    los.writeln(); // put out empty line
      }
  }

  // put out last boundary
  los.writeln(boundary + "--");
    }
View Full Code Here

TOP

Related Classes of com.google.code.com.sun.mail.util.LineOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.