1 20 package org.columba.mail.folder.mailboximport; 21 22 import java.io.BufferedReader ; 23 import java.io.File ; 24 import java.io.FileReader ; 25 26 import org.columba.api.command.IWorkerStatusController; 27 import org.columba.mail.folder.IMailbox; 28 import org.columba.mail.util.MailResourceLoader; 29 30 34 public class PegasusMailImporter extends AbstractMailboxImporter { 35 public PegasusMailImporter() { 36 super(); 37 } 38 39 public PegasusMailImporter(IMailbox destinationFolder, File [] sourceFiles) { 40 super(destinationFolder, sourceFiles); 41 } 42 43 public int getType() { 44 return TYPE_FILE; 45 } 46 47 public void importMailboxFile(File file, IWorkerStatusController worker, 48 IMailbox destFolder) throws Exception { 49 int count = 0; 50 boolean sucess = false; 51 52 StringBuffer strbuf = new StringBuffer (); 53 54 BufferedReader in = new BufferedReader (new FileReader (file)); 55 String str; 56 57 while ((str = in.readLine()) != null) { 59 if (worker.cancelled() == true) { 61 return; 62 } 63 64 if ((str.startsWith("From ???@???") == false) || 67 (str.length() == 0)) { 68 strbuf.append(str + "\n"); 69 } else { 70 if (strbuf.length() != 0) { 71 saveMessage(strbuf.toString(), worker, 73 getDestinationFolder()); 74 75 count++; 76 77 sucess = true; 78 } 79 80 strbuf = new StringBuffer (); 81 } 82 } 83 84 if ((sucess == true) && (strbuf.length() > 0)) { 87 saveMessage(strbuf.toString(), worker, getDestinationFolder()); 88 } 89 90 in.close(); 91 } 92 93 public String getDescription() { 94 return MailResourceLoader.getString("dialog", "mailboximport", 95 "PegasusMail_description"); 96 } 97 } 98 | Popular Tags |