javax.mail.Multipart.writeTo()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中javax.mail.Multipart.writeTo()方法的一些代码示例,展示了Multipart.writeTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Multipart.writeTo()方法的具体详情如下:
包路径:javax.mail.Multipart
类名称:Multipart
方法名:writeTo

Multipart.writeTo介绍

[英]Output an appropriately encoded bytestream to the given OutputStream. The implementation subclass decides the appropriate encoding algorithm to be used. The bytestream is typically used for sending.
[中]将经过适当编码的ByTestStream输出到给定的OutputStream。实现子类决定要使用的适当编码算法。字节流通常用于发送。

代码示例

代码示例来源:origin: com.sun.mail/javax.mail

/**
   * Write the object to the output stream, using the specific MIME type.
   */
  @Override
  public void writeTo(Object obj, String mimeType, OutputStream os) 
      throws IOException {
  if (obj instanceof Multipart) {
    try {
    ((Multipart)obj).writeTo(os);
    } catch (MessagingException e) {
    IOException ioex =
      new IOException("Exception writing Multipart");
    ioex.initCause(e);
    throw ioex;
    }
  }
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
   * Write the object to the output stream, using the specific MIME type.
   */
  public void writeTo(Object obj, String mimeType, OutputStream os) 
      throws IOException {
  if (obj instanceof Multipart) {
    try {
    ((Multipart)obj).writeTo(os);
    } catch (MessagingException e) {
    IOException ioex =
      new IOException("Exception writing Multipart");
    ioex.initCause(e);
    throw ioex;
    }
  }
  }
}

代码示例来源:origin: spring-projects/spring-integration

@Override
protected AbstractIntegrationMessageBuilder<String> doTransform(javax.mail.Message mailMessage)
    throws Exception { // NOSONAR
  Object content = mailMessage.getContent();
  if (content instanceof String) {
    return this.getMessageBuilderFactory().withPayload((String) content);
  }
  if (content instanceof Multipart) {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ((Multipart) content).writeTo(outputStream);
    return this.getMessageBuilderFactory().withPayload(
        new String(outputStream.toByteArray(), this.charset));
  }
  else if (content instanceof Part) {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ((Part) content).writeTo(outputStream);
    return this.getMessageBuilderFactory().withPayload(
        new String(outputStream.toByteArray(), this.charset));
  }
  throw new IllegalArgumentException("failed to transform contentType ["
      + mailMessage.getContentType() + "] to String.");
}

代码示例来源:origin: spring-projects/spring-integration

((Multipart) content).writeTo(baos);
content = byteArrayToContent(headers, baos);

代码示例来源:origin: com.sun.mail/mailapi

/**
   * Write the object to the output stream, using the specific MIME type.
   */
  @Override
  public void writeTo(Object obj, String mimeType, OutputStream os) 
      throws IOException {
  if (obj instanceof Multipart) {
    try {
    ((Multipart)obj).writeTo(os);
    } catch (MessagingException e) {
    IOException ioex =
      new IOException("Exception writing Multipart");
    ioex.initCause(e);
    throw ioex;
    }
  }
  }
}

代码示例来源:origin: com.sun.mail/jakarta.mail

/**
   * Write the object to the output stream, using the specific MIME type.
   */
  @Override
  public void writeTo(Object obj, String mimeType, OutputStream os) 
      throws IOException {
  if (obj instanceof Multipart) {
    try {
    ((Multipart)obj).writeTo(os);
    } catch (MessagingException e) {
    IOException ioex =
      new IOException("Exception writing Multipart");
    ioex.initCause(e);
    throw ioex;
    }
  }
  }
}

代码示例来源:origin: org.glassfish.metro/webservices-extra

/**
   * Write the object to the output stream, using the specific MIME type.
   */
  @Override
  public void writeTo(Object obj, String mimeType, OutputStream os) 
      throws IOException {
  if (obj instanceof Multipart) {
    try {
    ((Multipart)obj).writeTo(os);
    } catch (MessagingException e) {
    IOException ioex =
      new IOException("Exception writing Multipart");
    ioex.initCause(e);
    throw ioex;
    }
  }
  }
}

代码示例来源:origin: com.sun.mail/android-mail

/**
   * Write the object to the output stream, using the specific MIME type.
   */
  @Override
  public void writeTo(Object obj, String mimeType, OutputStream os) 
      throws IOException {
  if (obj instanceof Multipart) {
    try {
    ((Multipart)obj).writeTo(os);
    } catch (MessagingException e) {
    IOException ioex =
      new IOException("Exception writing Multipart");
    ioex.initCause(e);
    throw ioex;
    }
  }
  }
}

代码示例来源:origin: jboss/jboss-javaee-specs

/**
   * Write the object to the output stream, using the specific MIME type.
   */
  @Override
  public void writeTo(Object obj, String mimeType, OutputStream os) 
      throws IOException {
  if (obj instanceof Multipart) {
    try {
    ((Multipart)obj).writeTo(os);
    } catch (MessagingException e) {
    IOException ioex =
      new IOException("Exception writing Multipart");
    ioex.initCause(e);
    throw ioex;
    }
  }
  }
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs

/**
   * @see MessageBodyWriter#writeTo(Object, Class, Type, Annotation[],
   *      MediaType, MultivaluedMap, OutputStream)
   */
  public void writeTo(Multipart multipart, Class<?> type, Type genericType,
      Annotation[] annotations, MediaType mediaType,
      MultivaluedMap<String, Object> httpHeaders,
      OutputStream entityStream) throws IOException {
    try {
      multipart.writeTo(entityStream);
    } catch (MessagingException e) {
      if (e.getCause() instanceof IOException) {
        throw (IOException) e.getCause();
      }
      final IOException ioExc = new IOException(
          "Could not serialize the Multipart");
      ioExc.initCause(e);
      throw ioExc;
    }
  }
}

代码示例来源:origin: stackoverflow.com

connection.setRequestProperty("Accept", "application/json");
connection.setDoOutput(true);
body.writeTo(connection.getOutputStream());

代码示例来源:origin: org.springframework.integration/spring-integration-mail

@Override
protected AbstractIntegrationMessageBuilder<String> doTransform(javax.mail.Message mailMessage) throws Exception {
  Object content = mailMessage.getContent();
  if (content instanceof String) {
    return this.getMessageBuilderFactory().withPayload((String) content);
  }
  if (content instanceof Multipart) {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ((Multipart) content).writeTo(outputStream);
    return this.getMessageBuilderFactory().withPayload(
        new String(outputStream.toByteArray(), this.charset));
  }
  else if (content instanceof Part) {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ((Part) content).writeTo(outputStream);
    return this.getMessageBuilderFactory().withPayload(
        new String(outputStream.toByteArray(), this.charset));
  }
  throw new IllegalArgumentException("failed to transform contentType ["
      + mailMessage.getContentType() + "] to String.");
}

代码示例来源:origin: org.springframework.integration/spring-integration-mail

((Multipart) content).writeTo(baos);
content = byteArrayToContent(headers, baos);

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

multipart.writeTo(os);
  this.message.setContent(os.toString(), contentTypeHeader);
} else {

相关文章