Example usage for org.apache.commons.cli CommandLine getArgs

List of usage examples for org.apache.commons.cli CommandLine getArgs

Introduction

In this page you can find the example usage for org.apache.commons.cli CommandLine getArgs.

Prototype

public String[] getArgs() 

Source Link

Document

Retrieve any left-over non-recognized options and arguments

Usage

From source file:com.basingwerk.utilisation.Utilisation.java

public static void main(final String[] args) {
    String dataFile = null;//from   w  w w.j av a2 s  .c  om

    Options options = new Options();

    Option helpOption = new Option("h", "help", false, "print this help");
    Option serverURLOption = new Option("l", "logfile", true, "log file");

    options.addOption(helpOption);
    options.addOption(serverURLOption);

    CommandLineParser argsParser = new PosixParser();

    try {
        CommandLine commandLine = argsParser.parse(options, args);

        if (commandLine.hasOption(helpOption.getOpt())) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("Usage grapher", options);
            System.exit(0);
        }

        dataFile = commandLine.getOptionValue(serverURLOption.getOpt());
        String[] otherArgs = commandLine.getArgs();

        if (dataFile == null || otherArgs.length > 1) {
            System.out.println("Please specify a logfile");
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("Usage grapher", options);
            System.exit(0);
        }

    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
    }

    final UsagePlotter demo = new UsagePlotter("Usage", new File(dataFile));
    demo.pack();
    RefineryUtilities.centerFrameOnScreen(demo);
    demo.setVisible(true);
}

From source file:com.arsdigita.util.parameter.ParameterPrinter.java

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

    CommandLine line = null;
    try {/*from   w  w  w . j  a v  a  2s  .c  o m*/
        line = new PosixParser().parse(OPTIONS, args);
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }

    String[] outFile = line.getArgs();
    if (outFile.length != 1) {
        System.out.println("Usage: ParameterPrinter [--html] [--file config-list-file] output-file");
        System.exit(1);
    }
    if (line.hasOption("usage")) {
        System.out.println("Usage: ParameterPrinter [--html] [--file config-list-file] output-file");
        System.exit(0);
    }

    if (line.hasOption("file")) {
        String file = line.getOptionValue("file");
        try {
            BufferedReader reader = new BufferedReader(new FileReader(file));
            String configClass;
            while ((configClass = reader.readLine()) != null) {
                register(configClass);
            }
        } catch (IOException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
    } else {
        register("com.arsdigita.runtime.RuntimeConfig");
        register("com.arsdigita.web.WebConfig");
        register("com.arsdigita.templating.TemplatingConfig");
        register("com.arsdigita.kernel.KernelConfig");
        register("com.arsdigita.kernel.security.SecurityConfig");
        register("com.arsdigita.mail.MailConfig");
        register("com.arsdigita.versioning.VersioningConfig");
        register("com.arsdigita.search.SearchConfig");
        register("com.arsdigita.search.lucene.LuceneConfig");
        register("com.arsdigita.kernel.security.SecurityConfig");
        register("com.arsdigita.bebop.BebopConfig");
        register("com.arsdigita.dispatcher.DispatcherConfig");
        register("com.arsdigita.workflow.simple.WorkflowConfig");
        register("com.arsdigita.cms.ContentSectionConfig");
    }

    if (line.hasOption("html")) {
        final StringWriter sout = new StringWriter();
        final PrintWriter out = new PrintWriter(sout);

        writeXML(out);

        final XSLTemplate template = new XSLTemplate(
                ParameterPrinter.class.getResource("ParameterPrinter_html.xsl"));

        final Source source = new StreamSource(new StringReader(sout.toString()));
        final Result result = new StreamResult(new File(outFile[0]));

        template.transform(source, result);
    } else {
        final PrintWriter out = new PrintWriter(new FileWriter(outFile[0]));

        writeXML(out);
    }
}

From source file:com.genentech.chemistry.openEye.apps.SDFMDLSSSMatcher.java

public static void main(String... args) throws IOException, InterruptedException {
    oechem.OEUseJavaHeap(false);/*w  w  w .j  a  v  a2 s  . c  o m*/

    // create command line Options object
    Options options = new Options();
    Option opt = new Option("in", true, "input file [.sdf,...]");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("out", true, "output file oe-supported");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("ref", true, "refrence file with MDL query molecules");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("anyMatch", false, "if set all matches are reported not just the first.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("printAll", false, "if set even compounds that do not macht are outputted.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("nCpu", true, "number of CPU's used in parallel, dafault 1");
    opt.setRequired(false);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }

    args = cmd.getArgs();
    if (args.length > 0) {
        exitWithHelp("Unknown param: " + args[0], options);
    }

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    int nCpu = 1;
    boolean firstMatch = !cmd.hasOption("anyMatch");
    boolean printAll = cmd.hasOption("printAll");

    String d = cmd.getOptionValue("nCpu");
    if (d != null)
        nCpu = Integer.parseInt(d);

    String inFile = cmd.getOptionValue("in");
    String outFile = cmd.getOptionValue("out");
    String refFile = cmd.getOptionValue("ref");

    SDFMDLSSSMatcher matcher = new SDFMDLSSSMatcher(refFile, outFile, firstMatch, printAll, nCpu);
    matcher.run(inFile);
    matcher.close();
}

From source file:edu.msu.cme.rdp.readseq.writers.StkWriter.java

public static void main(String[] args) throws Exception {
    Options options = new Options();
    options.addOption("r", "removeref", false, "is set, do not write the GC reference sequences to output");
    options.addOption("h", "header", true,
            "the header of the output file in case a differenet stk version, default is " + STK_HEADER);
    String header = STK_HEADER;/*w  w w  .j av a2  s .  com*/
    boolean removeRef = false;

    try {
        CommandLine line = new PosixParser().parse(options, args);

        if (line.hasOption("removeref")) {
            removeRef = true;
        }
        if (line.hasOption("header")) {
            header = line.getOptionValue("header");
        }

        args = line.getArgs();
        if (args.length < 2) {
            throw new Exception("Need input and output files");
        }

    } catch (Exception e) {
        new HelpFormatter().printHelp("USAGE: to-stk <input-file> <out-file>", options);
        System.err.println("ERROR: " + e.getMessage());
        System.exit(1);
        return;
    }

    SequenceReader reader = new SequenceReader(new File(args[0]));
    PrintStream out = new PrintStream(new File(args[1]));
    StkWriter writer = new StkWriter(reader, out, header);
    reader = new SequenceReader(new File(args[0]));
    Sequence seq;
    while ((seq = reader.readNextSequence()) != null) {
        if (seq.getSeqName().startsWith("#") && removeRef) {
            continue;
        }
        writer.writeSeq(seq);
    }
    writer.writeEndOfBlock();
    writer.close();
    reader.close();

}

From source file:com.ctriposs.rest4j.tools.data.FilterSchemaGenerator.java

public static void main(String[] args) {
    final CommandLineParser parser = new GnuParser();
    CommandLine cl = null;
    try {//from w  ww.ja va2 s . c  o  m
        cl = parser.parse(_options, args);
    } catch (ParseException e) {
        _log.error("Invalid arguments: " + e.getMessage());
        reportInvalidArguments();
    }

    final String[] directoryArgs = cl.getArgs();
    if (directoryArgs.length != 2) {
        reportInvalidArguments();
    }

    final File sourceDirectory = new File(directoryArgs[0]);
    if (!sourceDirectory.exists()) {
        _log.error(sourceDirectory.getPath() + " does not exist");
        System.exit(1);
    }
    if (!sourceDirectory.isDirectory()) {
        _log.error(sourceDirectory.getPath() + " is not a directory");
        System.exit(1);
    }
    final URI sourceDirectoryURI = sourceDirectory.toURI();

    final File outputDirectory = new File(directoryArgs[1]);
    if (outputDirectory.exists() && !sourceDirectory.isDirectory()) {
        _log.error(outputDirectory.getPath() + " is not a directory");
        System.exit(1);
    }

    final boolean isAvroMode = cl.hasOption('a');
    final String predicateExpression = cl.getOptionValue('e');
    final Predicate predicate = PredicateExpressionParser.parse(predicateExpression);

    final Collection<File> sourceFiles = FileUtil.listFiles(sourceDirectory, null);
    int exitCode = 0;
    for (File sourceFile : sourceFiles) {
        try {
            final ValidationOptions val = new ValidationOptions();
            val.setAvroUnionMode(isAvroMode);

            final SchemaParser schemaParser = new SchemaParser();
            schemaParser.setValidationOptions(val);

            schemaParser.parse(new FileInputStream(sourceFile));
            if (schemaParser.hasError()) {
                _log.error("Error parsing " + sourceFile.getPath() + ": "
                        + schemaParser.errorMessageBuilder().toString());
                exitCode = 1;
                continue;
            }

            final DataSchema originalSchema = schemaParser.topLevelDataSchemas().get(0);
            if (!(originalSchema instanceof NamedDataSchema)) {
                _log.error(sourceFile.getPath() + " does not contain valid NamedDataSchema");
                exitCode = 1;
                continue;
            }

            final SchemaParser filterParser = new SchemaParser();
            filterParser.setValidationOptions(val);

            final NamedDataSchema filteredSchema = Filters.removeByPredicate((NamedDataSchema) originalSchema,
                    predicate, filterParser);
            if (filterParser.hasError()) {
                _log.error("Error applying predicate: " + filterParser.errorMessageBuilder().toString());
                exitCode = 1;
                continue;
            }

            final String relativePath = sourceDirectoryURI.relativize(sourceFile.toURI()).getPath();
            final String outputFilePath = outputDirectory.getPath() + File.separator + relativePath;
            final File outputFile = new File(outputFilePath);
            final File outputFileParent = outputFile.getParentFile();
            outputFileParent.mkdirs();
            if (!outputFileParent.exists()) {
                _log.error("Unable to write filtered schema to " + outputFileParent.getPath());
                exitCode = 1;
                continue;
            }

            FileOutputStream fout = new FileOutputStream(outputFile);
            fout.write(filteredSchema.toString().getBytes(RestConstants.DEFAULT_CHARSET));
            fout.close();
        } catch (IOException e) {
            _log.error(e.getMessage());
            exitCode = 1;
        }
    }

    System.exit(exitCode);
}

From source file:ee.ria.xroad.common.conf.globalconf.ConfigurationClientMain.java

/**
 * Main entry point of configuration client. Based on the arguments,
 * the client will either:/*  w ww  .  j  av  a2 s . c om*/
 * 1) <anchor file> <configuration path> -- download and exit
 * 2) <anchor file> -- download and verify
 * 3) [no args] -- start as daemon
 * @param args the arguments
 * @throws Exception if an error occurs
 */
public static void main(String[] args) throws Exception {
    CommandLine cmd = getCommandLine(args);

    String[] actualArgs = cmd.getArgs();
    if (actualArgs.length == NUM_ARGS_FROM_CONF_PROXY_FULL) {
        // Run configuration client in one-shot mode downloading the specified global configuration version
        System.exit(download(actualArgs[0], actualArgs[1], actualArgs[2]));
    } else if (actualArgs.length == NUM_ARGS_FROM_CONF_PROXY) {
        // Run configuration client in one-shot mode downloading the current global configuration version
        System.exit(download(actualArgs[0], actualArgs[1],
                String.format("%d", SystemProperties.CURRENT_GLOBAL_CONFIGURATION_VERSION)));
    } else if (actualArgs.length == 1) {
        // Run configuration client in validate mode
        System.exit(validate(actualArgs[0], getParamsValidator(cmd)));
    } else {
        // Run configuration client in daemon mode
        startDaemon();
    }
}

From source file:com.google.testing.pogen.PageObjectGenerator.java

@SuppressWarnings("static-access")
public static void main(String[] args) {
    if (args.length == 0) {
        printUsage(System.out);/*w  w w.j a  va2s. c  om*/
        return;
    }

    String commandName = args[0];
    // @formatter:off
    Options options = new Options()
            .addOption(OptionBuilder.withDescription(
                    "Attribute name to be assigned in tagas containing template variables (default is 'id').")
                    .hasArg().withLongOpt("attr").create('a'))
            .addOption(OptionBuilder.withDescription("Print help for this command.").withLongOpt("help")
                    .create('h'))
            .addOption(OptionBuilder.withDescription("Print processed files verbosely.").withLongOpt("verbose")
                    .create('v'));
    // @formatter:on

    String helpMessage = null;
    if (commandName.equals(GENERATE_COMMAND)) {
        // @formatter:off
        options.addOption(OptionBuilder.withDescription("Package name of generating skeleton test code.")
                .hasArg().isRequired().withLongOpt("package").create('p'))
                .addOption(OptionBuilder.withDescription("Output directory of generating skeleton test code.")
                        .hasArg().isRequired().withLongOpt("out").create('o'))
                .addOption(OptionBuilder.withDescription(
                        "Root input directory of html template files for analyzing the suffixes of the package name.")
                        .hasArg().isRequired().withLongOpt("in").create('i'))
                .addOption(OptionBuilder.withDescription("Regex for finding html template files.").hasArg()
                        .withLongOpt("regex").create('e'))
                .addOption(OptionBuilder.withDescription("Option for finding html template files recursively.")
                        .withLongOpt("recursive").create('r'));
        // @formatter:on
        helpMessage = "java PageObjectGenerator generate -o <test_out_dir> -p <package_name> -i <root_directory> "
                + " [OPTIONS] <template_file1> <template_file2> ...\n"
                + "e.g. java PageObjectGenerator generate -a class -o PageObjectGeneratorTest/src/test/java/com/google/testing/pogen/pages"
                + " -i PageObjectGeneratorTest/src/main/resources -p com.google.testing.pogen.pages -e (.*)\\.html -v";
    } else if (commandName.equals(MEASURE_COMMAND)) {
        helpMessage = "java PageObjectGenerator measure [OPTIONS] <template_file1> <template_file2> ...";
    } else if (commandName.equals(LIST_COMMAND)) {
        helpMessage = "java PageObjectGenerator list <template_file1> <template_file2> ...";
    } else {
        System.err.format("'%s' is not a PageObjectGenerator command.", commandName);
        printUsage(System.err);
        System.exit(-1);
    }

    BasicParser cmdParser = new BasicParser();
    HelpFormatter f = new HelpFormatter();
    try {
        CommandLine cl = cmdParser.parse(options, Arrays.copyOfRange(args, 1, args.length));
        if (cl.hasOption('h')) {
            f.printHelp(helpMessage, options);
            return;
        }

        Command command = null;
        String[] templatePaths = cl.getArgs();
        String attributeName = cl.getOptionValue('a');
        attributeName = attributeName != null ? attributeName : "id";
        if (commandName.equals(GENERATE_COMMAND)) {
            String rootDirectoryPath = cl.getOptionValue('i');
            String templateFilePattern = cl.getOptionValue('e');
            boolean isRecusive = cl.hasOption('r');
            command = new GenerateCommand(templatePaths, cl.getOptionValue('o'), cl.getOptionValue('p'),
                    attributeName, cl.hasOption('v'), rootDirectoryPath, templateFilePattern, isRecusive);
        } else if (commandName.equals(MEASURE_COMMAND)) {
            command = new MeasureCommand(templatePaths, attributeName, cl.hasOption('v'));
        } else if (commandName.equals(LIST_COMMAND)) {
            command = new ListCommand(templatePaths, attributeName);
        }
        try {
            command.execute();
            return;
        } catch (FileProcessException e) {
            System.err.println(e.getMessage());
        } catch (IOException e) {
            System.err.println("Errors occur in processing files.");
            System.err.println(e.getMessage());
        }
    } catch (ParseException e) {
        System.err.println("Errors occur in parsing the command arguments.");
        System.err.println(e.getMessage());
        f.printHelp(helpMessage, options);
    }
    System.exit(-1);
}

From source file:com.github.r351574nc3.amex.assignment1.App.java

public static void main(final String... args) {
    if (args.length < 1) {
        printUsage();/*from   w  ww. j  a  v  a  2  s .  co  m*/
        System.exit(0);
    }

    final Options options = new Options();
    options.addOption(OptionBuilder.withArgName("output").hasArg(true).withDescription("Path for CSV output")
            .create("o"));
    options.addOption(
            OptionBuilder.withArgName("input").hasArg(true).withDescription("Path for CSV input").create("i"));

    final CommandLineParser parser = new BasicParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        printUsage();
        System.exit(0);
    }

    if ((cmd.hasOption('o') && cmd.hasOption('i')) || !(cmd.hasOption('o') || cmd.hasOption('i'))
            || (cmd.hasOption('o') && cmd.getArgs().length < 1)) {
        printUsage();
        System.exit(0);
    }

    if (cmd.hasOption('o') && cmd.getArgs().length > 0) {
        final String outputName = cmd.getOptionValue("o");
        final int iterations = Integer.parseInt(cmd.getArgs()[cmd.getArgs().length - 1]);
        new App().run(new File(outputName), iterations);
    } else if (cmd.hasOption('i')) {
        final String inputName = cmd.getOptionValue("i");
        new App().run(new File(inputName));
    }

    System.exit(0);
}

From source file:com.basistech.ninja.Train.java

/**
 * Command line interface to train a model.
 *
 * <pre>//from   w  ww . j a  va 2  s.  c  o  m
 *  usage: Train [options]
 *  --batch-size <arg>      batch size (default = 10)
 *  --epochs <arg>          epochs (default = 5)
 *  --examples <arg>        input examples file (required)
 *  --layer-sizes <arg>     layer sizes, including input/output, e.g. 3 4 2 (required)
 *  --learning-rate <arg>   learning-rate (default = 0.7)
 *  --model <arg>           output model file (required)
 * </pre>
 *
 * @param args command line arguments
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    String defaultBatchSize = "10";
    String deafaultEpochs = "5";
    String defaultLearningRate = "0.7";

    Options options = new Options();
    Option option;
    option = new Option(null, "examples", true, "input examples file (required)");
    option.setRequired(true);
    options.addOption(option);
    option = new Option(null, "model", true, "output model file (required)");
    option.setRequired(true);
    options.addOption(option);
    option = new Option(null, "layer-sizes", true,
            "layer sizes, including input/output, e.g. 3 4 2 (required)");
    option.setRequired(true);
    option.setArgs(Option.UNLIMITED_VALUES);
    options.addOption(option);
    option = new Option(null, "batch-size", true, String.format("batch size (default = %s)", defaultBatchSize));
    options.addOption(option);
    option = new Option(null, "epochs", true, String.format("epochs (default = %s)", deafaultEpochs));
    options.addOption(option);
    option = new Option(null, "learning-rate", true,
            String.format("learning-rate (default = %s)", defaultLearningRate));
    options.addOption(option);

    CommandLineParser parser = new GnuParser();
    CommandLine cmdline = null;
    try {
        cmdline = parser.parse(options, args);
    } catch (org.apache.commons.cli.ParseException e) {
        System.err.println(e.getMessage());
        usage(options);
        System.exit(1);
    }
    String[] remaining = cmdline.getArgs();
    if (remaining == null) {
        usage(options);
        System.exit(1);
    }

    List<Integer> layerSizes = Lists.newArrayList();
    for (String s : cmdline.getOptionValues("layer-sizes")) {
        layerSizes.add(Integer.parseInt(s));
    }

    File examplesFile = new File(cmdline.getOptionValue("examples"));
    Train that = new Train(layerSizes, examplesFile);
    int batchSize = Integer.parseInt(cmdline.getOptionValue("batch-size", defaultBatchSize));
    int epochs = Integer.parseInt(cmdline.getOptionValue("epochs", deafaultEpochs));
    double learningRate = Double.parseDouble(cmdline.getOptionValue("learning-rate", defaultLearningRate));
    File modelFile = new File(cmdline.getOptionValue("model"));

    that.train(batchSize, epochs, learningRate, modelFile);
}

From source file:com.genentech.struchk.sdfNormalizer.java

public static void main(String[] args) {
    long start = System.currentTimeMillis();
    int nMessages = 0;
    int nErrors = 0;
    int nStruct = 0;

    // create command line Options object
    Options options = new Options();
    Option opt = new Option("in", true, "input file [.ism,.sdf,...]");
    opt.setRequired(true);//from w  w w  .  j ava  2s.com
    options.addOption(opt);

    opt = new Option("out", true, "output file");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("mol", true, "molFile used for output: ORIGINAL(def)|NORMALIZED|TAUTOMERIC");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("shortMessage", false,
            "Limit message to first 80 characters to conform with sdf file specs.");
    opt.setRequired(false);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        exitWithHelp(options, e.getMessage());
        throw new Error(e); // avoid compiler errors
    }
    args = cmd.getArgs();

    if (args.length != 0) {
        System.err.print("Unknown options: " + args + "\n\n");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("sdfNormalizer", options);
        System.exit(1);
    }

    String molOpt = cmd.getOptionValue("mol");
    OUTMolFormat outMol = OUTMolFormat.ORIGINAL;
    if (molOpt == null || "original".equalsIgnoreCase(molOpt))
        outMol = OUTMolFormat.ORIGINAL;
    else if ("NORMALIZED".equalsIgnoreCase(molOpt))
        outMol = OUTMolFormat.NORMALIZED;
    else if ("TAUTOMERIC".equalsIgnoreCase(molOpt))
        outMol = OUTMolFormat.TAUTOMERIC;
    else {
        System.err.printf("Unkown option for -mol: %s\n", molOpt);
        System.exit(1);
    }

    String inFile = cmd.getOptionValue("in");
    String outFile = cmd.getOptionValue("out");
    boolean limitMessage = cmd.hasOption("shortMessage");

    try {
        oemolistream ifs = new oemolistream(inFile);
        oemolostream ofs = new oemolostream(outFile);

        URL cFile = OEStruchk.getResourceURL(OEStruchk.class, "Struchk.xml");

        // create OEStruchk from config file
        OEStruchk strchk = new OEStruchk(cFile, CHECKConfig.ASSIGNStructFlag, false);

        OEGraphMol mol = new OEGraphMol();
        StringBuilder sb = new StringBuilder(2000);
        while (oechem.OEReadMolecule(ifs, mol)) {
            if (!strchk.applyRules(mol, null))
                nErrors++;

            switch (outMol) {
            case NORMALIZED:
                mol.Clear();
                oechem.OEAddMols(mol, strchk.getTransformedMol("parent"));
                break;
            case TAUTOMERIC:
                mol.Clear();
                oechem.OEAddMols(mol, strchk.getTransformedMol(null));
                break;
            case ORIGINAL:
                break;
            }

            oechem.OESetSDData(mol, "CTISMILES", strchk.getTransformedIsoSmiles(null));
            oechem.OESetSDData(mol, "CTSMILES", strchk.getTransformedSmiles(null));
            oechem.OESetSDData(mol, "CISMILES", strchk.getTransformedIsoSmiles("parent"));
            oechem.OESetSDData(mol, "Strutct_Flag", strchk.getStructureFlag().getName());

            List<Message> msgs = strchk.getStructureMessages(null);
            nMessages += msgs.size();
            for (Message msg : msgs)
                sb.append(String.format("\t%s:%s", msg.getLevel(), msg.getText()));
            if (limitMessage)
                sb.setLength(Math.min(sb.length(), 80));

            oechem.OESetSDData(mol, "NORM_MESSAGE", sb.toString());

            oechem.OEWriteMolecule(ofs, mol);

            sb.setLength(0);
            nStruct++;
        }
        strchk.delete();
        mol.delete();
        ifs.close();
        ifs.delete();
        ofs.close();
        ofs.delete();

    } catch (Exception e) {
        throw new Error(e);
    } finally {
        System.err.printf("sdfNormalizer: Checked %d structures %d errors, %d messages in %dsec\n", nStruct,
                nErrors, nMessages, (System.currentTimeMillis() - start) / 1000);
    }
}