Example usage for java.lang IllegalArgumentException printStackTrace

List of usage examples for java.lang IllegalArgumentException printStackTrace

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.comcast.tvx.haproxy.MappingsLoaderMain.java

/**
 * @param args//from  w w w  .  j  ava 2  s.  com
 */
public static void main(String[] args) {

    try {
        Args.parse(MappingsLoaderMain.class, args);
    } catch (IllegalArgumentException e) {

        System.out.println(e.getMessage());
        Args.usage(MappingsLoaderMain.class);
        System.exit(1);
    }

    final CuratorFramework curatorFramework = CuratorClient.getCuratorFramework(zooKeeperConnectionString);
    try {
        loadMappings(curatorFramework);
    } catch (Exception e) {
        curatorFramework.close();
        e.printStackTrace();
        System.exit(1);
    }
    curatorFramework.close();
    System.exit(0);

}

From source file:net.dv8tion.jda.player.Bot.java

public static void main(String[] args) {
    try {// w ww  . j  a  v  a2  s . c  om
        JSONObject obj = new JSONObject(new String(Files.readAllBytes(Paths.get("Config.json"))));
        JDA api = new JDABuilder().setBotToken(obj.getString("botToken")).addListener(new Bot())
                .buildBlocking();

    } catch (IllegalArgumentException e) {
        System.out.println("The config was not populated. Please provide a token.");
    } catch (LoginException e) {
        System.out.println("The provided botToken was incorrect. Please provide valid details.");
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        System.err.println(
                "Encountered a JSON error. Most likely caused due to an outdated or ill-formated config.\n"
                        + "Please delete the config so that it can be regenerated. JSON Error:\n");
        e.printStackTrace();
    } catch (IOException e) {
        JSONObject obj = new JSONObject();
        obj.put("botToken", "");
        try {
            Files.write(Paths.get("Config.json"), obj.toString(4).getBytes());
            System.out.println("No config file was found. Config.json has been generated, please populate it!");
        } catch (IOException e1) {
            System.out.println("No config file was found and we failed to generate one.");
            e1.printStackTrace();
        }
    }
}

From source file:org.jclouds.vfs.tools.blobstore.BlobStoreShell.java

public static void main(String... args) {

    if (args.length != 1)
        throw new IllegalArgumentException(INVALID_SYNTAX);
    URI location;/*from w  w  w  . j a  v a 2  s.  c  om*/
    try {
        location = HttpUtils.createUri(args[0]);
        checkArgument(location.getScheme().equals("blobstore"), "wrong scheme");
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException(String.format("%s%n%s", e.getMessage(), INVALID_SYNTAX));
    }
    try {
        (new BlobStoreShell(args[0])).go();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
    System.exit(0);
}

From source file:hk.idv.kenson.jrconsole.Console.java

/**
 * @param args//from  www  .j av  a2 s .c o  m
 */
public static void main(String[] args) {
    try {
        Map<String, Object> params = Console.parseArgs(args);
        if (params.containsKey("help")) {
            printUsage();
            return;
        }
        if (params.containsKey("version")) {
            System.err.println("Version: " + VERSION);
            return;
        }
        if (params.containsKey("debug")) {
            for (String key : params.keySet())
                log.info("\"" + key + "\" => \"" + params.get(key) + "\"");
            return;
        }

        checkParam(params);
        stepCompile(params);
        JasperReport jasper = stepLoadReport(params);
        JasperPrint print = stepFill(jasper, params);
        InputStream stream = stepExport(print, params);

        File output = new File(params.get("output").toString());
        FileOutputStream fos = new FileOutputStream(output);
        copy(stream, fos);

        fos.close();
        stream.close();
        System.out.println(output.getAbsolutePath()); //Output the report path for pipe
    } catch (IllegalArgumentException ex) {
        printUsage();
        System.err.println("Error: " + ex.getMessage());
        ex.printStackTrace();
    } catch (RuntimeException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new RuntimeException("Unexpected exception", ex);
    }
}

From source file:de.fuberlin.agcsw.svont.changedetection.smartcex.PartitionEL.java

public static void main(String[] args) {
    if (args.length != 4) {
        usage();/*from  ww w .  j  a  v a  2  s  .c  o m*/
    }

    String compatibilityModeStr = args[0];
    ReasonerCompatibilityMode compatiblilityMode = null;
    try {
        compatiblilityMode = ReasonerCompatibilityMode.valueOf(compatibilityModeStr);
    } catch (IllegalArgumentException e) {
        usage();
    }

    try {
        Pair<OWLOntology, OWLOntology> result = partition(IRI.create(new File(args[1])), compatiblilityMode);
        result.getLeft().getOWLOntologyManager().saveOntology(result.getLeft(), IRI.create(new File(args[2])));
        result.getRight().getOWLOntologyManager().saveOntology(result.getRight(),
                IRI.create(new File(args[3])));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:io.seldon.importer.articles.ItemAttributesImporter.java

/**
 * @param args//from   w  w w.  j a  v a 2  s.  com
 * @throws InterruptedException 
 * @throws FileNotFoundException 
 */
public static void main(String[] args) throws InterruptedException, FileNotFoundException {

    FailFast failFast = new FailFast(Thread.currentThread());
    { // Fail Fast thread
        Thread fail_fast_thread = new Thread(failFast);
        fail_fast_thread.setName("fail_fast_thread");
        fail_fast_thread.start();
    }

    try {
        Args.parse(ItemAttributesImporter.class, args);
        { // Determine opMode by checking for urlFile
            if (urlFile != null) {
                opMode = OperationMode.OPERATION_MODE_FILE_IMPORTER;
            }
        }

        DefaultApiClient client = new DefaultApiClient(apiUrl, consumerKey, consumerSecret, API_TIMEOUT);

        ItemAttributesImporter fixer = new ItemAttributesImporter(client);

        fixer.setFailFast(failFast);
        fixer.run();

    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        Args.usage(ItemAttributesImporter.class);
    }
}

From source file:io.seldon.importer.articles.GeneralItemAttributesImporter.java

/**
* @param args/*from  w  ww  . j  a va  2 s.  co m*/
* @throws InterruptedException 
* @throws FileNotFoundException 
*/
public static void main(String[] args) throws InterruptedException, FileNotFoundException {

    FailFast failFast = new FailFast(Thread.currentThread());
    { // Fail Fast thread
        Thread fail_fast_thread = new Thread(failFast);
        fail_fast_thread.setName("fail_fast_thread");
        fail_fast_thread.start();
    }

    try {
        Args.parse(GeneralItemAttributesImporter.class, args);

        UrlFetcher urlFetcher = null;
        { // setup the correct UrlFetcher
            if (jsSupport) {
                urlFetcher = new JsSupporedUrlFetcher(httpGetTimeout);
            } else {
                urlFetcher = new SimpleUrlFetcher(httpGetTimeout);
            }
        }

        { // Determine opMode by checking for urlFile
            if (urlFile != null) {
                opMode = OperationMode.OPERATION_MODE_FILE_IMPORTER;
            }
        }
        { // setup the attribute_detail_list
            attribute_detail_list = getAttributeDetailList(attributesConfigFile);
        }
        if (testUrl != null) {
            test_url_and_exit(urlFetcher, testUrl);
        }

        DefaultApiClient client = new DefaultApiClient(apiUrl, consumerKey, consumerSecret, API_TIMEOUT);

        GeneralItemAttributesImporter fixer = new GeneralItemAttributesImporter(client);

        fixer.setFailFast(failFast);
        fixer.run(urlFetcher);

    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        Args.usage(GeneralItemAttributesImporter.class);
    } catch (Exception e) {
        e.printStackTrace();
        Args.usage(GeneralItemAttributesImporter.class);
    }
}

From source file:edu.harvard.liblab.ecru.LoadCsvData.java

/**
 * @param args/*from   www.jav  a 2 s  .  c  o  m*/
 */
public static void main(String[] args) {
    if (args.length > 7 | args.length == 0 || !args[0].equals("-f") || !args[2].equals("-u")
            || !args[4].equals("-i")) {
        System.err.println(USAGE);
        System.exit(1);
    }
    String filename = args[1].trim();
    url = args[3].trim();
    needsPrefix = !args[5].equals("unique");
    isVerbose = (args.length == 7 && args[6].equals("-v"));
    System.out.println("Loading data from " + filename + " " + (needsPrefix ? "IDs will be prefixed " : " "));
    long start = System.currentTimeMillis();
    boolean isReading = false;
    CSVPrinter printer = null;

    CSVFormat format = CSVFormat.EXCEL.withHeader().withDelimiter(',').withAllowMissingColumnNames(true);
    CSVParser parser;
    try {
        if (isVerbose) {
            printer = new CSVPrinter(System.err, format.withDelimiter('|'));
        }
        parser = CSVParser.parse(new File(filename), Charset.forName("UTF-8"), format);

        solrSrvr = SingletonSolrServer.getSolrServer(url);
        for (CSVRecord record : parser) {
            numRecs++;
            HashMap<String, String> recMap = new HashMap<String, String>();
            for (String field : FIELDS) {
                String value = null;
                try {
                    value = record.get(field);
                } catch (IllegalArgumentException e) {
                    if (e.getMessage().indexOf("expected one of") == -1) {
                        e.printStackTrace();
                        System.exit(1);
                    }
                }
                value = value == null ? "" : value.trim();
                recMap.put(field, value);
            }
            String id = recMap.get("ID");
            if (id.isEmpty()) {
                if (isVerbose) {
                    System.err.println("Record missing ID: ");
                    printer.printRecord(record);
                }
            } else {
                String type = recMap.get("Type");
                SolrDocument sdoc = getDocFromSolr(recMap.get("ID"));
                try {
                    if (type.toLowerCase().equals("course")) {
                        processCourse(recMap, sdoc);
                        isReading = false;
                    } else {
                        if (!isReading) {
                            addUpdateCommit(); // just in case the preceeding course(s) are related
                        }
                        processReading(recMap, sdoc);
                        isReading = true;
                    }
                } catch (Exception e) {
                    if (isVerbose) {
                        System.err.println("Record # " + numRecs + " not used:\n\t" + e.getMessage());
                    }
                    errRecs++;
                }
            }
            if (beans.size() > 20) {
                addUpdateCommit();
            }
        }
        parser.close();
        if (beans.size() > 0 || docUpdates.size() > 0) {
            addUpdateCommit();
        }
    } catch (FileNotFoundException e) {
        System.err.println(filename + " not found");
        System.exit(1);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
    long end = System.currentTimeMillis();
    long courseTime = (end - start) / (long) 1000;
    try {
        solrSrvr.optimize();
    } catch (SolrServerException e) {
        e.printStackTrace();
        System.exit(1);
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    }
    System.out.println(numRecs + " records found, of which " + errRecs + " had a problem; time: " + courseTime
            + " seconds " + ((courseTime > 60) ? ("(" + (courseTime / (long) 60) + " minutes)") : ""));
    System.exit(0);
}

From source file:jh.tools.office.ConvertOutPDF.java

public static void main(String[] args) throws Exception {

    try {//from www  .  jav a 2  s .  c  om
        getInputFilePath(args);
    } catch (IllegalArgumentException e) {
    }

    // Font regex (optional)
    // Set regex if you want to restrict to some defined subset of fonts
    // Here we have to do this before calling createContent,
    // since that discovers fonts
    String regex = null;
    // Windows:
    // String
    // regex=".*(calibri|camb|cour|arial|symb|times|Times|zapf).*";
    //regex=".*(calibri|camb|cour|arial|times|comic|georgia|impact|LSANS|pala|tahoma|trebuc|verdana|symbol|webdings|wingding).*";
    // Mac
    // String
    // regex=".*(Courier New|Arial|Times New Roman|Comic Sans|Georgia|Impact|Lucida Console|Lucida Sans Unicode|Palatino Linotype|Tahoma|Trebuchet|Verdana|Symbol|Webdings|Wingdings|MS Sans Serif|MS Serif).*";
    PhysicalFonts.setRegex(regex);

    // Document loading (required)
    WordprocessingMLPackage wordMLPackage;

    // Load .docx or Flat OPC .xml
    System.out.println("Loading file from " + inputfilepath);
    wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));

    // Refresh the values of DOCPROPERTY fields
    FieldUpdater updater = new FieldUpdater(wordMLPackage);
    //updater.update(true);

    String outputfilepath;
    if (inputfilepath == null) {
        outputfilepath = System.getProperty("user.dir") + "/OUT_FontContent.pdf";
    } else {
        outputfilepath = inputfilepath + ".pdf";
    }

    // All methods write to an output stream
    OutputStream os = new java.io.FileOutputStream(outputfilepath);

    if (!Docx4J.pdfViaFO()) {

        // Since 3.3.0, Plutext's PDF Converter is used by default

        System.out.println("Using Plutext's PDF Converter; add docx4j-export-fo if you don't want that");

        try {
            Docx4J.toPDF(wordMLPackage, os);
        } catch (Docx4JException e) {
            e.printStackTrace();
            // What did we write?
            IOUtils.closeQuietly(os);
            System.out.println(FileUtils.readFileToString(new File(outputfilepath)));
            if (e.getCause() != null && e.getCause() instanceof ConversionException) {

                ConversionException ce = (ConversionException) e.getCause();
                ce.printStackTrace();
            }
        }
        System.out.println("Saved: " + outputfilepath);

        return;
    }

    System.out.println("Attempting to use XSL FO");

    /**
     * Demo of PDF output.
     *
     * PDF output is via XSL FO.
     * First XSL FO is created, then FOP
     * is used to convert that to PDF.
     *
     * Don't worry if you get a class not
     * found warning relating to batik. It
     * doesn't matter.
     *
     * If you don't have logging configured,
     * your PDF will say "TO HIDE THESE MESSAGES,
     * TURN OFF debug level logging for
     * org.docx4j.convert.out.pdf.viaXSLFO".  The thinking is
     * that you need to be able to be warned if there
     * are things in your docx which the PDF output
     * doesn't support...
     *
     * docx4j used to also support creating
     * PDF via iText and via HTML. As of docx4j 2.5.0,
     * only viaXSLFO is supported.  The viaIText and
     * viaHTML source code can be found in src/docx4j-extras directory
     *
     */

    /*
     * NOT WORKING?
     *
     * If you are getting:
     *
     *   "fo:layout-master-set" must be declared before "fo:page-sequence"
     *
     * please check:
     *
     * 1.  the jaxb-xslfo jar is on your classpath
     *
     * 2.  that there is no stack trace earlier in the logs
     *
     * 3.  your JVM has adequate memory, eg
     *
     *           -Xmx1G -XX:MaxPermSize=128m
     *
     */

    // Set up font mapper (optional)
    Mapper fontMapper = new IdentityPlusMapper();
    wordMLPackage.setFontMapper(fontMapper);
    fontMapper.put("", PhysicalFonts.get("LiSu"));
    fontMapper.put("", PhysicalFonts.get("SimSun"));
    fontMapper.put("", PhysicalFonts.get("Microsoft Yahei"));
    fontMapper.put("", PhysicalFonts.get("SimHei"));
    fontMapper.put("", PhysicalFonts.get("KaiTi"));
    fontMapper.put("", PhysicalFonts.get("NSimSun"));
    fontMapper.put("?", PhysicalFonts.get("STXingkai"));
    fontMapper.put("?", PhysicalFonts.get("STFangsong"));
    fontMapper.put("", PhysicalFonts.get("simsun-extB"));
    fontMapper.put("", PhysicalFonts.get("FangSong"));
    fontMapper.put("_GB2312", PhysicalFonts.get("FangSong_GB2312"));
    fontMapper.put("", PhysicalFonts.get("YouYuan"));
    fontMapper.put("?", PhysicalFonts.get("STSong"));
    fontMapper.put("?", PhysicalFonts.get("STZhongsong"));

    // .. example of mapping font Times New Roman which doesn't have certain Arabic glyphs
    // eg Glyph "" (0x64a, afii57450) not available in font "TimesNewRomanPS-ItalicMT".
    // eg Glyph "" (0x62c, afii57420) not available in font "TimesNewRomanPS-ItalicMT".
    // to a font which does
    PhysicalFont font = PhysicalFonts.get("Arial Unicode MS");
    // make sure this is in your regex (if any)!!!
    //      if (font!=null) {
    //         fontMapper.put("Times New Roman", font);
    //         fontMapper.put("Arial", font);
    //      }
    //      fontMapper.put("Libian SC Regular", PhysicalFonts.get("SimSun"));

    // FO exporter setup (required)
    // .. the FOSettings object
    FOSettings foSettings = Docx4J.createFOSettings();
    if (saveFO) {
        foSettings.setFoDumpFile(new java.io.File(inputfilepath + ".fo"));
    }
    foSettings.setWmlPackage(wordMLPackage);

    // Document format:
    // The default implementation of the FORenderer that uses Apache Fop will output
    // a PDF document if nothing is passed via
    // foSettings.setApacheFopMime(apacheFopMime)
    // apacheFopMime can be any of the output formats defined in org.apache.fop.apps.MimeConstants eg org.apache.fop.apps.MimeConstants.MIME_FOP_IF or
    // FOSettings.INTERNAL_FO_MIME if you want the fo document as the result.
    //foSettings.setApacheFopMime(FOSettings.INTERNAL_FO_MIME);

    // Specify whether PDF export uses XSLT or not to create the FO
    // (XSLT takes longer, but is more complete).

    // Don't care what type of exporter you use
    Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);

    // Prefer the exporter, that uses a xsl transformation
    // Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);

    // Prefer the exporter, that doesn't use a xsl transformation (= uses a visitor)
    // .. faster, but not yet at feature parity
    // Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_NONXSL);

    System.out.println("Saved: " + outputfilepath);

    // Clean up, so any ObfuscatedFontPart temp files can be deleted
    if (wordMLPackage.getMainDocumentPart().getFontTablePart() != null) {
        wordMLPackage.getMainDocumentPart().getFontTablePart().deleteEmbeddedFontTempFiles();
    }
    // This would also do it, via finalize() methods
    updater = null;
    foSettings = null;
    wordMLPackage = null;

}

From source file:org.docx4j.samples.ConvertOutPDF.java

public static void main(String[] args) throws Exception {

    try {//from ww w  .  j  av  a  2 s.c om
        getInputFilePath(args);
    } catch (IllegalArgumentException e) {
    }

    // Font regex (optional)
    // Set regex if you want to restrict to some defined subset of fonts
    // Here we have to do this before calling createContent,
    // since that discovers fonts
    String regex = null;
    // Windows:
    // String
    // regex=".*(calibri|camb|cour|arial|symb|times|Times|zapf).*";
    //regex=".*(calibri|camb|cour|arial|times|comic|georgia|impact|LSANS|pala|tahoma|trebuc|verdana|symbol|webdings|wingding).*";
    // Mac
    // String
    // regex=".*(Courier New|Arial|Times New Roman|Comic Sans|Georgia|Impact|Lucida Console|Lucida Sans Unicode|Palatino Linotype|Tahoma|Trebuchet|Verdana|Symbol|Webdings|Wingdings|MS Sans Serif|MS Serif).*";
    PhysicalFonts.setRegex(regex);

    // Document loading (required)
    WordprocessingMLPackage wordMLPackage;
    if (inputfilepath == null) {
        // Create a docx
        System.out.println("No imput path passed, creating dummy document");
        wordMLPackage = WordprocessingMLPackage.createPackage();
        SampleDocument.createContent(wordMLPackage.getMainDocumentPart());
    } else {
        // Load .docx or Flat OPC .xml
        System.out.println("Loading file from " + inputfilepath);
        wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));
    }

    // Refresh the values of DOCPROPERTY fields 
    FieldUpdater updater = new FieldUpdater(wordMLPackage);
    updater.update(true);

    String outputfilepath;
    if (inputfilepath == null) {
        outputfilepath = System.getProperty("user.dir") + "/OUT_FontContent.pdf";
    } else {
        outputfilepath = inputfilepath + ".pdf";
    }

    // All methods write to an output stream
    OutputStream os = new java.io.FileOutputStream(outputfilepath);

    if (!Docx4J.pdfViaFO()) {

        // Since 3.3.0, Plutext's PDF Converter is used by default

        System.out.println("Using Plutext's PDF Converter; add docx4j-export-fo if you don't want that");

        try {
            Docx4J.toPDF(wordMLPackage, os);
        } catch (Docx4JException e) {
            e.printStackTrace();
            // What did we write?
            IOUtils.closeQuietly(os);
            System.out.println(FileUtils.readFileToString(new File(outputfilepath)));
            if (e.getCause() != null && e.getCause() instanceof ConversionException) {

                ConversionException ce = (ConversionException) e.getCause();
                ce.printStackTrace();
            }
        }
        System.out.println("Saved: " + outputfilepath);

        return;
    }

    System.out.println("Attempting to use XSL FO");

    /**
     * Demo of PDF output.
     * 
     * PDF output is via XSL FO.
     * First XSL FO is created, then FOP
     * is used to convert that to PDF.
     * 
     * Don't worry if you get a class not
     * found warning relating to batik. It
     * doesn't matter.
     * 
     * If you don't have logging configured, 
     * your PDF will say "TO HIDE THESE MESSAGES, 
     * TURN OFF debug level logging for 
     * org.docx4j.convert.out.pdf.viaXSLFO".  The thinking is
     * that you need to be able to be warned if there
     * are things in your docx which the PDF output
     * doesn't support...
     * 
     * docx4j used to also support creating
     * PDF via iText and via HTML. As of docx4j 2.5.0, 
     * only viaXSLFO is supported.  The viaIText and 
     * viaHTML source code can be found in src/docx4j-extras directory
     *
     */

    /*
     * NOT WORKING?
     * 
     * If you are getting:
     * 
     *   "fo:layout-master-set" must be declared before "fo:page-sequence"
     * 
     * please check:
     * 
     * 1.  the jaxb-xslfo jar is on your classpath
     * 
     * 2.  that there is no stack trace earlier in the logs
     * 
     * 3.  your JVM has adequate memory, eg
     * 
     *           -Xmx1G -XX:MaxPermSize=128m
     * 
     */

    // Set up font mapper (optional)
    Mapper fontMapper = new IdentityPlusMapper();
    wordMLPackage.setFontMapper(fontMapper);

    // .. example of mapping font Times New Roman which doesn't have certain Arabic glyphs
    // eg Glyph "" (0x64a, afii57450) not available in font "TimesNewRomanPS-ItalicMT".
    // eg Glyph "" (0x62c, afii57420) not available in font "TimesNewRomanPS-ItalicMT".
    // to a font which does
    PhysicalFont font = PhysicalFonts.get("Arial Unicode MS");
    // make sure this is in your regex (if any)!!!
    //      if (font!=null) {
    //         fontMapper.put("Times New Roman", font);
    //         fontMapper.put("Arial", font);
    //      }
    //      fontMapper.put("Libian SC Regular", PhysicalFonts.get("SimSun"));

    // FO exporter setup (required)
    // .. the FOSettings object
    FOSettings foSettings = Docx4J.createFOSettings();
    if (saveFO) {
        foSettings.setFoDumpFile(new java.io.File(inputfilepath + ".fo"));
    }
    foSettings.setWmlPackage(wordMLPackage);

    // Document format: 
    // The default implementation of the FORenderer that uses Apache Fop will output
    // a PDF document if nothing is passed via 
    // foSettings.setApacheFopMime(apacheFopMime)
    // apacheFopMime can be any of the output formats defined in org.apache.fop.apps.MimeConstants eg org.apache.fop.apps.MimeConstants.MIME_FOP_IF or
    // FOSettings.INTERNAL_FO_MIME if you want the fo document as the result.
    //foSettings.setApacheFopMime(FOSettings.INTERNAL_FO_MIME);

    // Specify whether PDF export uses XSLT or not to create the FO
    // (XSLT takes longer, but is more complete).

    // Don't care what type of exporter you use
    Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);

    // Prefer the exporter, that uses a xsl transformation
    // Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);

    // Prefer the exporter, that doesn't use a xsl transformation (= uses a visitor)
    // .. faster, but not yet at feature parity
    // Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_NONXSL);

    System.out.println("Saved: " + outputfilepath);

    // Clean up, so any ObfuscatedFontPart temp files can be deleted 
    if (wordMLPackage.getMainDocumentPart().getFontTablePart() != null) {
        wordMLPackage.getMainDocumentPart().getFontTablePart().deleteEmbeddedFontTempFiles();
    }
    // This would also do it, via finalize() methods
    updater = null;
    foSettings = null;
    wordMLPackage = null;

}