1 17 package org.columba.mail.folder.mailboximport; 18 19 import java.io.BufferedReader ; 20 import java.io.File ; 21 import java.io.FileReader ; 22 23 import org.columba.api.command.IWorkerStatusController; 24 import org.columba.mail.folder.IMailbox; 25 import org.columba.mail.folder.mh.MHMessageFileFilter; 26 27 33 public class MHImporter extends AbstractMailboxImporter { 34 public MHImporter() { 35 super(); 36 } 37 38 42 public MHImporter(IMailbox destinationFolder, File [] sourceFiles) { 43 super(destinationFolder, sourceFiles); 44 } 45 46 public int getType() { 47 return TYPE_DIRECTORY; 48 } 49 50 53 public void importMailboxFile(File directory, 54 IWorkerStatusController worker, IMailbox destFolder) 55 throws Exception { 56 File [] list = directory.listFiles(MHMessageFileFilter.getInstance()); 57 58 for (int i = 0; i < list.length; i++) { 59 File file = list[i]; 60 61 String name = file.getName(); 62 63 if (name.equals(".") || name.equals("..")) { 64 continue; 65 } 66 67 if (name.startsWith(".")) { 68 continue; 69 } 70 71 if ((file.exists()) && (file.length() > 0)) { 72 importMessage(file, worker); 73 } 74 } 75 } 76 77 protected void importMessage(File file, IWorkerStatusController worker) 78 throws Exception { 79 StringBuffer strbuf = new StringBuffer (); 80 81 BufferedReader in = new BufferedReader (new FileReader (file)); 82 String str; 83 strbuf = new StringBuffer (); 84 85 while ((str = in.readLine()) != null) { 86 strbuf.append(str + "\n"); 87 } 88 89 in.close(); 90 91 saveMessage(strbuf.toString(), worker, getDestinationFolder()); 92 } 93 94 public String getDescription() { 95 return ""; 97 } 98 } 99 | Popular Tags |