mboxIterator = MboxIterator.fromFile(mbox) .charset(charset) .maxMessageSize(messageSize) .build() .iterator(); } catch (IOException ioe) {
@Override protected void doInitialize(UimaContext context) throws ResourceInitializationException { // Initialise charset for MBOX processing try { charset = Charset.forName(charsetName); } catch (UnsupportedCharsetException | IllegalCharsetNameException ce) { getMonitor().warn("Unsupported charset, {}. UTF-8 will be used.", charsetName, ce); charset = StandardCharsets.UTF_8; } // Initialise MBOX iterator try { mboxIterator = MboxIterator.fromFile(mbox) .charset(charset) .maxMessageSize(messageSize) .build() .iterator(); } catch (IOException ioe) { throw new ResourceInitializationException(ioe); } // Initialise message parser messageBuilder = new DefaultMessageBuilder(); messageBuilder.setContentDecoding(true); MimeConfig config = new MimeConfig.Builder().setMaxLineLen(10000).build(); messageBuilder.setMimeEntityConfig(config); // Build list of extensions to ignore for (String s : ignoreExtensions) { ignoreExtensionsList.add(s.trim().toLowerCase()); } }
public static void main(String[] args) throws Exception { if (args.length != 1) { System.out.println("Please supply a path to an mbox file to parse"); } final File mbox = new File(args[0]); long start = System.currentTimeMillis(); int count = 0; for (CharBufferWrapper message : MboxIterator.fromFile(mbox).charset(ENCODER.charset()).build()) { // saveMessageToFile(count, buf); System.out.println(messageSummary(message.asInputStream(ENCODER.charset()))); count++; } System.out.println("Found " + count + " messages"); long end = System.currentTimeMillis(); System.out.println("Done in: " + (end - start) + " milis"); }
public static Builder fromFile(String file) { return new Builder(file); }
public static Builder fromFile(File filePath) { return new Builder(filePath); }