Class IMAPImportMbox


  • public final class IMAPImportMbox
    extends java.lang.Object
    This is an example program demonstrating how to use the IMAP[S]Client class. This program connects to a IMAP[S] server and imports messages into the folder from an mbox file.

    Usage: IMAPImportMbox imap[s]://user:password@host[:port]/folder/path [selectors]

    An example selector might be:

    • 1,2,3,7-10
    • -142986- : this is useful for retrieving messages by apmail number, which appears as From xyz-return-142986-apmail-...

    For example:
    IMAPImportMbox imaps://user:pass@imap.googlemail.com/imported_messages 201401.mbox 1-10,20 -142986-

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String CRLF  
      private static java.util.regex.Pattern PATFROM  
    • Constructor Summary

      Constructors 
      Constructor Description
      IMAPImportMbox()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String getDate​(java.lang.String msg)  
      private static boolean listContains​(java.util.List<java.lang.String> contains, java.lang.String string)
      Is at least one entry in the list contained in the string?
      static void main​(java.lang.String[] args)  
      private static boolean process​(java.lang.StringBuilder sb, IMAPClient imap, java.lang.String folder, int msgNum)  
      private static boolean startsWith​(java.lang.String input, java.util.regex.Pattern pat)  
      private static boolean wanted​(int msgNum, java.lang.String line, java.util.BitSet msgNums, java.util.List<java.lang.String> contains)
      Is the message wanted?
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PATFROM

        private static final java.util.regex.Pattern PATFROM
    • Constructor Detail

      • IMAPImportMbox

        public IMAPImportMbox()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • startsWith

        private static boolean startsWith​(java.lang.String input,
                                          java.util.regex.Pattern pat)
      • getDate

        private static java.lang.String getDate​(java.lang.String msg)
      • process

        private static boolean process​(java.lang.StringBuilder sb,
                                       IMAPClient imap,
                                       java.lang.String folder,
                                       int msgNum)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • wanted

        private static boolean wanted​(int msgNum,
                                      java.lang.String line,
                                      java.util.BitSet msgNums,
                                      java.util.List<java.lang.String> contains)
        Is the message wanted?
        Parameters:
        msgNum - the message number
        line - the From line
        msgNums - the list of wanted message numbers
        contains - the list of strings to be contained
        Returns:
        true if the message is wanted
      • listContains

        private static boolean listContains​(java.util.List<java.lang.String> contains,
                                            java.lang.String string)
        Is at least one entry in the list contained in the string?
        Parameters:
        contains - the list of strings to look for
        string - the String to check against
        Returns:
        true if at least one entry in the contains list is contained in the string