javax.mail.internet.MimeMessage.getRawInputStream()方法的使用及代码示例

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

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

MimeMessage.getRawInputStream介绍

[英]Return an InputStream to the raw data with any Content-Transfer-Encoding intact. This method is useful if the "Content-Transfer-Encoding" header is incorrect or corrupt, which would prevent the getInputStream method or getContent method from returning the correct data. In such a case the application may use this method and attempt to decode the raw data itself.

This implementation simply calls the getContentStream method.
[中]将InputStream返回到原始数据,并保留所有内容传输编码。如果“内容传输编码”标题不正确或损坏,则此方法非常有用,这将阻止getInputStream方法或getContent方法返回正确的数据。在这种情况下,应用程序可以使用此方法并尝试解码原始数据本身。
这个实现只调用getContentStream方法。

代码示例

代码示例来源:origin: org.apache.james/james-server-core-library

/**
 * @see javax.mail.internet.MimeMessage#getRawInputStream()
 */
public InputStream getRawInputStream() throws MessagingException {
  return getWrappedMessage().getRawInputStream();
}

代码示例来源:origin: org.nhind/direct-common

/**
 * Parses the notification part fields of a MDN MimeMessage message.  The message is expected to conform to the MDN specification
 * as described in RFC3798.
 * @return The notification part fields as a set of Internet headers. 
 */		
public static InternetHeaders getNotificationFieldsAsHeaders(MimeMessage message)
{
  if (message == null)
    throw new IllegalArgumentException("Message can not be null");
  
  MimeMultipart mm = null;
  
  try
  {
    ByteArrayDataSource dataSource = new ByteArrayDataSource(message.getRawInputStream(), message.getContentType());
    mm = new MimeMultipart(dataSource);
  }
  catch (Exception e)
  {
    throw new IllegalArgumentException("Failed to parse notification fields.", e);
  }
  
  return getNotificationFieldsAsHeaders(mm);
}

代码示例来源:origin: DirectProject/nhin-d

/**
 * Parses the notification part fields of a MDN MimeMessage message.  The message is expected to conform to the MDN specification
 * as described in RFC3798.
 * @return The notification part fields as a set of Internet headers. 
 */		
public static InternetHeaders getNotificationFieldsAsHeaders(MimeMessage message)
{
  if (message == null)
    throw new IllegalArgumentException("Message can not be null");
  
  MimeMultipart mm = null;
  
  try
  {
    ByteArrayDataSource dataSource = new ByteArrayDataSource(message.getRawInputStream(), message.getContentType());
    mm = new MimeMultipart(dataSource);
  }
  catch (Exception e)
  {
    throw new IllegalArgumentException("Failed to parse notification fields.", e);
  }
  
  return getNotificationFieldsAsHeaders(mm);
}

代码示例来源:origin: org.apache.james/james-server-jmap

private MimeBodyPart createMimeBodyPartWithContentHeadersFromMimeMessage(MimeMessage mimeMessage, List<Header> contentHeaders) throws MessagingException {
  MimeBodyPart fileBody = new MimeBodyPart(mimeMessage.getRawInputStream());
  for (Header header : contentHeaders) {
    fileBody.setHeader(header.getName(), header.getValue());
  }
  fileBody.setDisposition(Part.ATTACHMENT);
  return fileBody;
}

代码示例来源:origin: org.apache.james/james-server-core-library

bis = message.getRawInputStream();
  bos = bodyOs;
} catch(javax.mail.MessagingException _) {
  bis = message.getRawInputStream();
  bos = bodyOs;
} catch(javax.mail.MessagingException _) {

代码示例来源:origin: org.apache.james/james-server-core-library

/**
 * @see javax.mail.internet.MimeMessage#getRawInputStream()
 */
public InputStream getRawInputStream() throws MessagingException {
  if (!messageParsed && !isModified() && source != null) {
    InputStream is;
    try {
      is = source.getInputStream();
      // skip the headers.
      new MailHeaders(is);
      return is;
    } catch (IOException e) {
      throw new MessagingException("Unable to read the stream: " + e.getMessage(), e);
    }
  } else return super.getRawInputStream();
}

代码示例来源:origin: org.nhind/agent

/**
 * Parses the notification part fields of a MDN MimeMessage message.  The message is expected to conform to the MDN specification
 * as described in RFC3798.
 * @return The notification part fields as a set of Internet headers. 
 */		
public static InternetHeaders getNotificationFieldsAsHeaders(MimeMessage message)
{
  if (message == null)
    throw new IllegalArgumentException("Message can not be null");
  
  MimeMultipart mm = null;
  
  try
  {
    ByteArrayDataSource dataSource = new ByteArrayDataSource(message.getRawInputStream(), message.getContentType());
    mm = new MimeMultipart(dataSource);
  }
  catch (Exception e)
  {
    throw new NHINDException("Failed to parse notification fields.", e);
  }
  
  return getNotificationFieldsAsHeaders(mm);
}

代码示例来源:origin: mguessan/davmail

byte[] mimeContentCopy = new byte[((SharedByteArrayInputStream) mimeMessage.getRawInputStream()).available()];
int offset = mimeContent.length - mimeContentCopy.length;

代码示例来源:origin: org.apache.james/apache-standard-mailets

int len = bodyMax > 0 ? bodyMax : mail.getMessage().getSize();
StringBuffer text = new StringBuffer(len);
InputStream is = mail.getMessage().getRawInputStream();
byte[] buf = new byte[1024];
int read = 0;

代码示例来源:origin: mguessan/davmail

partInputStream = ((MimeMessage) bodyPart).getRawInputStream();
} else {
  partInputStream = ((MimeBodyPart) bodyPart).getRawInputStream();

代码示例来源:origin: org.apache.james/james-server-core-library

} else {
  try {
    in = new CombinedInputStream(new InputStream[] { new InternetHeadersInputStream(message.getAllHeaderLines()), message.getRawInputStream() });
  } catch (MessagingException e) {

相关文章

MimeMessage类方法