2 * @(#) $Id: FirstPlainPartExtractor.java,v 1.1.2.1 2004/09/29 00:57:59 otsuka Exp $
4 * Copyright (c) 2000 Shin Kinoshita All Rights Reserved.
6 package com.ozacc.mail.fetch.impl.sk_jp;
8 import java.io.IOException;
9 import javax.mail.Part;
10 import javax.mail.MessagingException;
11 import javax.mail.internet.ContentType;
14 * 最初に見つけたtext/plainパートの本文を得るPartHandlerです。
17 * @version $Revision: 1.1.2.1 $ $Date: 2004/09/29 00:57:59 $
20 public class FirstPlainPartExtractor implements PartHandler {
22 private String text = null;
24 public boolean processPart(Part part, ContentType context) throws MessagingException,
26 String type = part.getContentType();
27 // Bug fixed. Thx > ei
28 // http://www.sk-jp.com/cgi-bin/treebbs.cgi?kako=1&all=1292&s=1292
29 if (!part.isMimeType("text/plain") && type != null && !type.trim().equalsIgnoreCase("text")) {
32 text = (String)MultipartUtility.getContent(part);
36 public String getText() {
40 public static void main(String[] args) throws Exception {
41 javax.mail.internet.MimeMessage msg = new javax.mail.internet.MimeMessage(
42 javax.mail.Session.getDefaultInstance(System.getProperties(), null), System.in);
43 FirstPlainPartExtractor h = new FirstPlainPartExtractor();
44 MultipartUtility.process(msg, h);
46 System.out.println("This is the first detected text/plain part.");
47 System.out.println(h.getText());