本文整理匯總了Java中javax.mail.internet.MimeMessage.isMimeType方法的典型用法代碼示例。如果您正苦於以下問題:Java MimeMessage.isMimeType方法的具體用法?Java MimeMessage.isMimeType怎麽用?Java MimeMessage.isMimeType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.mail.internet.MimeMessage
的用法示例。
在下文中一共展示了MimeMessage.isMimeType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processMessage
import javax.mail.internet.MimeMessage; //導入方法依賴的package包/類
public void processMessage()
{
System.out.println("Process message");
try
{
Session session = Session.getDefaultInstance(new Properties());
InputStream inputStream = new ByteArrayInputStream(message.getBytes());
MimeMessage mimeMessage = new MimeMessage(session,inputStream);
if(mimeMessage.isMimeType(InboxVariables.plainMime))
{
plainMessage = mimeMessage.getContent().toString();
}
else if(mimeMessage.isMimeType(InboxVariables.multipartMime))
{
MimeMultipart mimeMultipart = (MimeMultipart) mimeMessage.getContent();
processMimeMultipart(mimeMultipart);
}
subject = mimeMessage.getSubject();
System.out.println("Message processed");
}
catch(Exception ex)
{
ex.printStackTrace(System.err);
}
}
示例2: getPart
import javax.mail.internet.MimeMessage; //導入方法依賴的package包/類
private static MessageBean getPart(MimeMessage message)
throws MessagingException, IOException {
if (message.isMimeType(TEXT_MIME_TYPE)) {
return createMessageBeanFromMessage(message, IOUtils.toString(message.getInputStream(), Charset.defaultCharset()).trim(), null);
} else if (message.isMimeType(MULTIPART_MIME_TYPE)) {
return getMessageBeanFromMultiPartMsg(message);
} else {
throw new MessagingException();
}
}