Example usage for java.lang Integer valueOf

List of usage examples for java.lang Integer valueOf

Introduction

In this page you can find the example usage for java.lang Integer valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Integer valueOf(int i) 

Source Link

Document

Returns an Integer instance representing the specified int value.

Usage

From source file:com.esri.geoevent.test.tools.RunTcpInTcpOutTest.java

public static void main(String args[]) {
    int numberEvents = 10000;
    //int brake = 1000;
    String server = "ags104";
    int in_port = 5565;
    int out_port = 5575;
    int start_rate = 5000;
    int end_rate = 5005;
    int rate_step = 1;

    Options opts = new Options();
    opts.addOption("n", true, "Number of Events");
    opts.addOption("s", true, "Server");
    opts.addOption("i", true, "Input TCP Port");
    opts.addOption("o", true, "Output TCP Port");
    opts.addOption("r", true, "Range");
    opts.addOption("h", false, "Help");
    try {/*www  .j a  v a 2 s  .  c o  m*/

        CommandLineParser parser = new BasicParser();
        CommandLine cmd = null;

        try {
            cmd = parser.parse(opts, args, false);
        } catch (ParseException ignore) {
            System.err.println(ignore.getMessage());
        }

        String cmdInputErrorMsg = "";

        if (cmd.getOptions().length == 0 || cmd.hasOption("h")) {
            throw new ParseException("Show Help");
        }

        if (cmd.hasOption("n")) {
            String val = cmd.getOptionValue("n");
            try {
                numberEvents = Integer.valueOf(val);
            } catch (NumberFormatException e) {
                cmdInputErrorMsg += "Invalid value for n. Must be integer.\n";
            }
        }

        if (cmd.hasOption("s")) {
            server = cmd.getOptionValue("s");
        }

        if (cmd.hasOption("i")) {
            String val = cmd.getOptionValue("i");
            try {
                in_port = Integer.valueOf(val);
            } catch (NumberFormatException e) {
                cmdInputErrorMsg += "Invalid value for i. Must be integer.\n";
            }
        }

        if (cmd.hasOption("o")) {
            String val = cmd.getOptionValue("o");
            try {
                out_port = Integer.valueOf(val);
            } catch (NumberFormatException e) {
                cmdInputErrorMsg += "Invalid value for o. Must be integer.\n";
            }
        }

        if (cmd.hasOption("r")) {
            String val = cmd.getOptionValue("r");
            try {
                String parts[] = val.split(",");
                if (parts.length == 3) {
                    start_rate = Integer.parseInt(parts[0]);
                    end_rate = Integer.parseInt(parts[1]);
                    rate_step = Integer.parseInt(parts[2]);
                } else if (parts.length == 1) {
                    // Run single rate
                    start_rate = Integer.parseInt(parts[0]);
                    end_rate = start_rate;
                    rate_step = start_rate;
                } else {
                    throw new ParseException("Rate must be three comma seperated values or a single value");
                }

            } catch (ParseException e) {
                cmdInputErrorMsg += e.getMessage();
            } catch (NumberFormatException e) {
                cmdInputErrorMsg += "Invalid value for r. Must be integers.\n";
            }
        }

        if (!cmdInputErrorMsg.equalsIgnoreCase("")) {
            throw new ParseException(cmdInputErrorMsg);
        }
        DecimalFormat df = new DecimalFormat("##0");
        RunTcpInTcpOutTest t = new RunTcpInTcpOutTest();

        if (start_rate == end_rate) {
            // Single Rate Test
            System.out.println("*********************************");
            System.out.println("Incremental testing at requested rate: " + start_rate);
            System.out.println("Count,Incremental Rate");

            t.runTest(numberEvents, start_rate, server, in_port, out_port, true);
            if (t.send_rate < 0 || t.rcv_rate < 0) {
                throw new Exception("Test Run Failed!");
            }
            System.out.println("Overall Average Send Rate, Received Rate");
            System.out.println(df.format(t.send_rate) + "," + df.format(t.rcv_rate));

        } else {
            System.out.println("*********************************");
            System.out.println("rateRqstd,avgSendRate,avgRcvdRate");

            //for (int rate: rates) {
            for (int rate = start_rate; rate <= end_rate; rate += rate_step) {

                t.runTest(numberEvents, rate, server, in_port, out_port, false);
                if (t.send_rate < 0 || t.rcv_rate < 0) {
                    throw new Exception("Test Run Failed!");
                }
                System.out.println(
                        Integer.toString(rate) + "," + df.format(t.send_rate) + "," + df.format(t.rcv_rate));
            }

        }

    } catch (ParseException e) {
        System.out.println("Invalid Command Options: ");
        System.out.println(e.getMessage());
        System.out.println(
                "Command line options: -n NumEvents -s Server -i InputPort -o OutputPort -r StartRate,EndRate,Step");

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

}

From source file:com.simple.sftpfetch.App.java

public static void main(String[] args) throws Exception {
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

    Options options = getOptions();//from  www. j ava2  s.  c  o  m

    List<String> requiredProperties = asList("c");

    CommandLineParser parser = new PosixParser();
    try {
        CommandLine commandLine = parser.parse(options, args);
        if (commandLine.hasOption("h")) {
            printUsage(options);
            System.exit(0);
        }

        for (String opt : requiredProperties) {
            if (!commandLine.hasOption(opt)) {
                System.err.println("The option: " + opt + " is required.");
                printUsage(options);
                System.exit(1);
            }
        }

        Pattern pattern;
        if (commandLine.hasOption("p")) {
            pattern = Pattern.compile(commandLine.getOptionValue("p"));
        } else {
            pattern = MATCH_EVERYTHING;
        }

        String filename = commandLine.getOptionValue("c");
        Properties properties = new Properties();
        try {
            InputStream stream = new FileInputStream(new File(filename));
            properties.load(stream);
        } catch (IOException ioe) {
            System.err.println("Unable to read properties from: " + filename);
            System.exit(2);
        }

        String routingKey = "";
        if (commandLine.hasOption("r")) {
            routingKey = commandLine.getOptionValue("r");
        } else if (properties.containsKey("rabbit.routingkey")) {
            routingKey = properties.getProperty("rabbit.routingkey");
        }

        int daysToFetch;
        if (commandLine.hasOption("d")) {
            daysToFetch = Integer.valueOf(commandLine.getOptionValue("d"));
        } else {
            daysToFetch = Integer.valueOf(properties.getProperty(FETCH_DAYS));
        }

        FileDecrypter decrypter = null;
        if (properties.containsKey("decryption.key.path")) {
            decrypter = new PGPFileDecrypter(new File(properties.getProperty("decryption.key.path")));
        } else {
            decrypter = new NoopDecrypter();
        }

        SftpClient sftpClient = new SftpClient(new JSch(), new SftpConnectionInfo(properties));
        try {
            App app = new App(sftpClient, s3FromProperties(properties),
                    new RabbitClient(new ConnectionFactory(), new RabbitConnectionInfo(properties)), decrypter,
                    System.out);
            app.run(routingKey, daysToFetch, pattern, commandLine.hasOption("n"), commandLine.hasOption("o"));
        } finally {
            sftpClient.close();
        }
        System.exit(0);
    } catch (UnrecognizedOptionException uoe) {
        System.err.println(uoe.getMessage());
        printUsage(options);
        System.exit(10);
    }
}

From source file:it.digitalhumanities.dhcpublisher.DHCPublisher.java

public static void main(String[] args) {

    if (args.length == 0) {
        usage();/*from  w  w  w.  jav  a2s .c  o m*/
    }

    try {
        Integer action = Integer.valueOf(args[0]);
        DHCPublisher dhcPublisher = new DHCPublisher();
        switch (action) {
        case 1: {
            if (args.length == 3) {
                dhcPublisher.unzip(args[1], args[2]);
            } else {
                usage();
            }
            break;
        }
        case 2: {
            if (args.length == 2) {
                dhcPublisher.convert(args[1]);
            } else {
                usage();
            }
            break;
        }
        case 3: {
            if (args.length == 3) {
                dhcPublisher.unzip(args[1], args[2]);
                dhcPublisher.convert(args[2]);
            } else {
                usage();
            }
            break;
        }
        default: {
            usage();
        }
        }
    } catch (Exception e) {
        e.printStackTrace();
        usage();
    }
}

From source file:com.linkedin.pinot.perf.StringDictionaryPerfTest.java

public static void main(String[] args) throws Exception {
    if (args.length != 2) {
        System.out.println("Usage: StringDictionaryPerfRunner <dictionary_length> <num_lookups> ");
    }/*from w ww  . j  ava  2s  .c o m*/

    int dictLength = Integer.valueOf(args[0]);
    int numLookups = Integer.valueOf(args[1]);

    StringDictionaryPerfTest test = new StringDictionaryPerfTest();
    test.buildSegment(dictLength);
    test.perfTestLookups(numLookups);
}

From source file:edu.msu.cme.rdp.kmer.KmerFilter.java

public static void main(String[] args) throws Exception {
    final KmerTrie kmerTrie;
    final SeqReader queryReader;
    final SequenceType querySeqType;
    final File queryFile;
    final KmerStartsWriter out;
    final boolean translQuery;
    final int wordSize;
    final int translTable;
    final boolean alignedSeqs;
    final List<String> refLabels = new ArrayList();
    final int maxThreads;

    try {/*from ww  w .  j a v a 2  s.c  o m*/
        CommandLine cmdLine = new PosixParser().parse(options, args);
        args = cmdLine.getArgs();

        if (args.length < 3) {
            throw new Exception("Unexpected number of arguments");
        }

        if (cmdLine.hasOption("out")) {
            out = new KmerStartsWriter(cmdLine.getOptionValue("out"));
        } else {
            out = new KmerStartsWriter(System.out);
        }

        if (cmdLine.hasOption("aligned")) {
            alignedSeqs = true;
        } else {
            alignedSeqs = false;
        }

        if (cmdLine.hasOption("transl-table")) {
            translTable = Integer.valueOf(cmdLine.getOptionValue("transl-table"));
        } else {
            translTable = 11;
        }

        if (cmdLine.hasOption("threads")) {
            maxThreads = Integer.valueOf(cmdLine.getOptionValue("threads"));
        } else {
            maxThreads = Runtime.getRuntime().availableProcessors();
        }

        queryFile = new File(args[1]);
        wordSize = Integer.valueOf(args[0]);
        SequenceType refSeqType = null;

        querySeqType = SeqUtils.guessSequenceType(queryFile);
        queryReader = new SequenceReader(queryFile);

        if (querySeqType == SequenceType.Protein) {
            throw new Exception("Expected nucl query sequences");
        }

        refSeqType = SeqUtils
                .guessSequenceType(new File(args[2].contains("=") ? args[2].split("=")[1] : args[2]));

        translQuery = refSeqType == SequenceType.Protein;

        if (translQuery && wordSize % 3 != 0) {
            throw new Exception("Word size must be a multiple of 3 for nucl ref seqs");
        }

        int trieWordSize;
        if (translQuery) {
            trieWordSize = wordSize / 3;
        } else {
            trieWordSize = wordSize;
        }
        kmerTrie = new KmerTrie(trieWordSize, translQuery);

        for (int index = 2; index < args.length; index++) {
            String refName;
            String refFileName = args[index];
            if (refFileName.contains("=")) {
                String[] lexemes = refFileName.split("=");
                refName = lexemes[0];
                refFileName = lexemes[1];
            } else {
                String tmpName = new File(refFileName).getName();
                if (tmpName.contains(".")) {
                    refName = tmpName.substring(0, tmpName.lastIndexOf("."));
                } else {
                    refName = tmpName;
                }
            }

            File refFile = new File(refFileName);

            if (refSeqType != SeqUtils.guessSequenceType(refFile)) {
                throw new Exception(
                        "Reference file " + refFile + " contains " + SeqUtils.guessFileFormat(refFile)
                                + " sequences but expected " + refSeqType + " sequences");
            }

            SequenceReader seqReader = new SequenceReader(refFile);
            Sequence seq;

            while ((seq = seqReader.readNextSequence()) != null) {
                if (seq.getSeqName().startsWith("#")) {
                    continue;
                }
                if (alignedSeqs) {
                    kmerTrie.addModelSequence(seq, refLabels.size());
                } else {
                    kmerTrie.addSequence(seq, refLabels.size());
                }
            }
            seqReader.close();

            refLabels.add(refName);
        }

    } catch (Exception e) {
        new HelpFormatter().printHelp("KmerSearch <word_size> <query_file> [name=]<ref_file> ...", options);
        System.err.println(e.getMessage());
        e.printStackTrace();
        System.exit(1);
        throw new RuntimeException("Stupid jvm"); //While this will never get thrown it is required to make sure javac doesn't get confused about uninitialized variables
    }

    long startTime = System.currentTimeMillis();
    long seqCount = 0;
    final int maxTasks = 25000;

    /*
     * if (args.length == 4) { maxThreads = Integer.valueOf(args[3]); } else {
     */

    //}

    System.err.println("Starting kmer mapping at " + new Date());
    System.err.println("*  Number of threads:       " + maxThreads);
    System.err.println("*  References:              " + refLabels);
    System.err.println("*  Reads file:              " + queryFile);
    System.err.println("*  Kmer length:             " + kmerTrie.getWordSize());

    final AtomicInteger processed = new AtomicInteger();
    final AtomicInteger outstandingTasks = new AtomicInteger();

    ExecutorService service = Executors.newFixedThreadPool(maxThreads);

    Sequence querySeq;

    while ((querySeq = queryReader.readNextSequence()) != null) {
        seqCount++;

        String seqString = querySeq.getSeqString();

        if (seqString.length() < 3) {
            System.err.println("Sequence " + querySeq.getSeqName() + "'s length is less than 3");
            continue;
        }

        final Sequence threadSeq = querySeq;

        Runnable r = new Runnable() {

            public void run() {
                try {
                    processSeq(threadSeq, refLabels, kmerTrie, out, wordSize, translQuery, translTable, false);
                    processSeq(threadSeq, refLabels, kmerTrie, out, wordSize, translQuery, translTable, true);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }

                processed.incrementAndGet();
                outstandingTasks.decrementAndGet();
            }
        };

        outstandingTasks.incrementAndGet();
        service.submit(r);

        while (outstandingTasks.get() >= maxTasks)
            ;

        if ((processed.get() + 1) % 1000000 == 0) {
            System.err.println("Processed " + processed + " sequences in "
                    + (System.currentTimeMillis() - startTime) + " ms");
        }
    }

    service.shutdown();
    service.awaitTermination(1, TimeUnit.DAYS);

    System.err.println("Finished Processed " + processed + " sequences in "
            + (System.currentTimeMillis() - startTime) + " ms");

    out.close();
}

From source file:com.github.brandtg.switchboard.FileLogAggregator.java

/** Main. */
public static void main(String[] args) throws Exception {
    Options opts = new Options();
    opts.addOption("h", "help", false, "Prints help message");
    opts.addOption("f", "file", true, "File to output aggregated logs to");
    opts.addOption("s", "separator", true, "Line separator in log");
    CommandLine cli = new GnuParser().parse(opts, args);

    if (cli.getArgs().length == 0 || cli.hasOption("help")) {
        new HelpFormatter().printHelp("usage: [opts] sourceHost:port ...", opts);
        System.exit(1);/*from w  w  w .  ja v  a 2  s  . c  o m*/
    }

    // Parse sources
    Set<InetSocketAddress> sources = new HashSet<>();
    for (int i = 0; i < cli.getArgs().length; i++) {
        String[] tokens = cli.getArgs()[i].split(":");
        sources.add(new InetSocketAddress(tokens[0], Integer.valueOf(tokens[1])));
    }

    // Parse output stream
    OutputStream outputStream;
    if (cli.hasOption("file")) {
        outputStream = new FileOutputStream(cli.getOptionValue("file"));
    } else {
        outputStream = System.out;
    }

    // Separator
    String separator = cli.getOptionValue("separator", "\n");
    if (separator.length() != 1) {
        throw new IllegalArgumentException("Separator must only be 1 character");
    }

    final FileLogAggregator fileLogAggregator = new FileLogAggregator(sources, separator.charAt(0),
            outputStream);

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            try {
                fileLogAggregator.stop();
            } catch (Exception e) {
                LOG.error("Error when stopping log aggregator", e);
            }
        }
    });

    fileLogAggregator.start();
}

From source file:com.github.brandtg.StlPlotter.java

public static void main(String[] args) throws Exception {
    List<Long> times = new ArrayList<>();
    List<Number> series = new ArrayList<>();
    try (InputStream is = new FileInputStream(args[1]);
            BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
        String line = reader.readLine(); // header
        while ((line = reader.readLine()) != null) {
            String[] tokens = line.split(",");
            times.add(Long.valueOf(tokens[0]));
            series.add(Double.valueOf(tokens[1]));
        }/*from w ww.ja  v a 2s  .c o  m*/
    }

    StlConfig config = new StlConfig();
    config.setNumberOfObservations(Integer.valueOf(args[0]));
    config.setNumberOfDataPoints(times.size());
    config.setNumberOfRobustnessIterations(1);
    config.setPeriodic(true);

    StlResult result = new StlDecomposition(config).decompose(times, series);

    plot(result);
}

From source file:com.sm.store.TestScanStoreClient.java

public static void main(String[] args) {
    String[] opts = new String[] { "-store", "-url", "-times" };
    String[] defaults = new String[] { "store", "localhost:7220", "40" };
    String[] paras = getOpts(args, opts, defaults);
    String store = paras[0];//from ww  w.j  a  v  a2 s.c o  m
    String url = paras[1];
    int times = Integer.valueOf(paras[2]);
    TestScanStoreClient tc = new TestScanStoreClient(store, url);
    tc.testMultiplePut(times);
    tc.testMultiGet(times);
    //        tc.test4Basic();
    tc.testInvoker();
    tc.testCursor();
    //        tc.testKeySet();
    //        tc.testGetTrigger();
    //        tc.testStorePara(times);

    tc.testScan(times);
    tc.close();
    System.exit(0);

}

From source file:io.pcp.parfait.benchmark.StandardMetricThroughPutBenchmark.java

public static void main(String[] args) throws InterruptedException, UnknownHostException {
    int numThreads = args.length < 1 ? Runtime.getRuntime().availableProcessors() : Integer.valueOf(args[0]);
    int numCounters = 1000;
    int iterations = 10000;

    ReportHelper.environmentReportHeader();
    ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
    System.out.printf("Thread Contention Supported: %s, Enabled by default: %s\n",
            threadMXBean.isThreadContentionMonitoringSupported(),
            threadMXBean.isThreadContentionMonitoringEnabled());
    System.out.printf("numThreads: %d, numCounters=%d, iterations=%d\n", numThreads, numCounters, iterations);

    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, false, false).runBenchmark();
    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, true, false).runBenchmark();
    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, true, true).runBenchmark();

    // now do it all again reverse, in case there's any JVM warmup issues unfairly treating the first/last runs
    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, true, true).runBenchmark();
    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, true, false).runBenchmark();
    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, false, false).runBenchmark();
}

From source file:de.morbz.osmpoispbf.Scanner.java

public static void main(String[] args) {
    System.out.println("OsmPoisPbf " + VERSION + " started");

    // Get input file
    if (args.length < 1) {
        System.out.println("Error: Please provide an input file");
        System.exit(-1);/*from   www .j av  a 2  s  .co  m*/
    }
    String inputFile = args[args.length - 1];

    // Get output file
    String outputFile;
    int index = inputFile.indexOf('.');
    if (index != -1) {
        outputFile = inputFile.substring(0, index);
    } else {
        outputFile = inputFile;
    }
    outputFile += ".csv";

    // Setup CLI parameters
    options = new Options();
    options.addOption("ff", "filterFile", true, "The file that is used to filter categories");
    options.addOption("of", "outputFile", true, "The output CSV file to be written");
    options.addOption("rt", "requiredTags", true, "Comma separated list of tags that are required [name]");
    options.addOption("ut", "undesiredTags", true,
            "Comma separated list of tags=value combinations that should be filtered [key=value]");
    options.addOption("ot", "outputTags", true, "Comma separated list of tags that are exported [name]");
    options.addOption("ph", "printHeader", false,
            "If flag is set, the `outputTags` are printed as first line in the output file.");
    options.addOption("r", "relations", false, "Parse relations");
    options.addOption("nw", "noWays", false, "Don't parse ways");
    options.addOption("nn", "noNodes", false, "Don't parse nodes");
    options.addOption("u", "allowUnclosedWays", false, "Allow ways that aren't closed");
    options.addOption("d", "decimals", true, "Number of decimal places of coordinates [7]");
    options.addOption("s", "separator", true, "Separator character for CSV [|]");
    options.addOption("v", "verbose", false, "Print all found POIs");
    options.addOption("h", "help", false, "Print this help");

    // Parse parameters
    CommandLine line = null;
    try {
        line = (new DefaultParser()).parse(options, args);
    } catch (ParseException exp) {
        System.err.println(exp.getMessage());
        printHelp();
        System.exit(-1);
    }

    // Help
    if (line.hasOption("help")) {
        printHelp();
        System.exit(0);
    }

    // Get filter file
    String filterFile = null;
    if (line.hasOption("filterFile")) {
        filterFile = line.getOptionValue("filterFile");
    }

    // Get output file
    if (line.hasOption("outputFile")) {
        outputFile = line.getOptionValue("outputFile");
    }

    // Check files
    if (inputFile.equals(outputFile)) {
        System.out.println("Error: Input and output files are the same");
        System.exit(-1);
    }
    File file = new File(inputFile);
    if (!file.exists()) {
        System.out.println("Error: Input file doesn't exist");
        System.exit(-1);
    }

    // Check OSM entity types
    boolean parseNodes = true;
    boolean parseWays = true;
    boolean parseRelations = false;
    if (line.hasOption("noNodes")) {
        parseNodes = false;
    }
    if (line.hasOption("noWays")) {
        parseWays = false;
    }
    if (line.hasOption("relations")) {
        parseRelations = true;
    }

    // Unclosed ways allowed?
    if (line.hasOption("allowUnclosedWays")) {
        onlyClosedWays = false;
    }

    // Get CSV separator
    char separator = '|';
    if (line.hasOption("separator")) {
        String arg = line.getOptionValue("separator");
        if (arg.length() != 1) {
            System.out.println("Error: The CSV separator has to be exactly 1 character");
            System.exit(-1);
        }
        separator = arg.charAt(0);
    }
    Poi.setSeparator(separator);

    // Set decimals
    int decimals = 7; // OSM default
    if (line.hasOption("decimals")) {
        String arg = line.getOptionValue("decimals");
        try {
            int dec = Integer.valueOf(arg);
            if (dec < 0) {
                System.out.println("Error: Decimals must not be less than 0");
                System.exit(-1);
            } else {
                decimals = dec;
            }
        } catch (NumberFormatException ex) {
            System.out.println("Error: Decimals have to be a number");
            System.exit(-1);
        }
    }
    Poi.setDecimals(decimals);

    // Verbose mode?
    if (line.hasOption("verbose")) {
        printPois = true;
    }

    // Required tags
    if (line.hasOption("requiredTags")) {
        String arg = line.getOptionValue("requiredTags");
        requiredTags = arg.split(",");
    }

    // Undesired tags
    if (line.hasOption("undesiredTags")) {
        String arg = line.getOptionValue("undesiredTags");
        undesiredTags = new HashMap<>();
        for (String undesired : arg.split(",")) {
            String[] keyVal = undesired.split("=");
            if (keyVal.length != 2) {
                System.out.println("Error: Undesired Tags have to formated like tag=value");
                System.exit(-1);
            }
            if (!undesiredTags.containsKey(keyVal[0])) {
                undesiredTags.put(keyVal[0], new HashSet<>(1));
            }
            undesiredTags.get(keyVal[0]).add(keyVal[1]);
        }
    }

    // Output tags
    if (line.hasOption("outputTags")) {
        String arg = line.getOptionValue("outputTags");
        outputTags = arg.split(",");
    }

    // Get filter rules
    FilterFileParser parser = new FilterFileParser(filterFile);
    filters = parser.parse();
    if (filters == null) {
        System.exit(-1);
    }

    // Setup CSV output
    try {
        writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF8"));
    } catch (IOException e) {
        System.out.println("Error: Output file error");
        System.exit(-1);
    }

    // Print Header
    if (line.hasOption("printHeader")) {
        String header = "category" + separator + "osm_id" + separator + "lat" + separator + "lon";
        for (int i = 0; i < outputTags.length; i++) {
            header += separator + outputTags[i];
        }
        try {
            writer.write(header + "\n");
        } catch (IOException e) {
            System.out.println("Error: Output file write error");
            System.exit(-1);
        }
    }

    // Setup OSMonaut
    EntityFilter filter = new EntityFilter(parseNodes, parseWays, parseRelations);
    Osmonaut naut = new Osmonaut(inputFile, filter, false);

    // Start watch
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();

    // Start OSMonaut
    String finalSeparator = String.valueOf(separator);
    naut.scan(new IOsmonautReceiver() {

        boolean entityNeeded;

        @Override
        public boolean needsEntity(EntityType type, Tags tags) {
            // Are there any tags?
            if (tags.size() == 0) {
                return false;
            }

            // Check required tags
            for (String tag : requiredTags) {
                if (!tags.hasKey(tag)) {
                    return false;
                }
            }

            entityNeeded = getCategory(tags, filters) != null;

            if (undesiredTags != null && entityNeeded) {
                for (String key : undesiredTags.keySet()) {
                    if (tags.hasKey(key)) {
                        for (String val : undesiredTags.get(key)) {
                            if (tags.hasKeyValue(key, val)) {
                                return false;
                            }
                        }
                    }
                }
            }

            return entityNeeded;
        }

        @Override
        public void foundEntity(Entity entity) {
            // Check if way is closed
            if (onlyClosedWays && entity.getEntityType() == EntityType.WAY) {
                if (!((Way) entity).isClosed()) {
                    return;
                }
            }

            // Get category
            Tags tags = entity.getTags();
            String cat = getCategory(tags, filters);
            if (cat == null) {
                return;
            }

            // Get center
            LatLon center = entity.getCenter();
            if (center == null) {
                return;
            }

            // Make OSM-ID
            String type = "";
            switch (entity.getEntityType()) {
            case NODE:
                type = "node";
                break;
            case WAY:
                type = "way";
                break;
            case RELATION:
                type = "relation";
                break;
            }
            String id = String.valueOf(entity.getId());

            // Make output tags
            String[] values = new String[outputTags.length];
            for (int i = 0; i < outputTags.length; i++) {
                String key = outputTags[i];
                if (tags.hasKey(key)) {
                    values[i] = tags.get(key).replaceAll(finalSeparator, "").replaceAll("\"", "");
                }
            }

            // Make POI
            poisFound++;
            Poi poi = new Poi(values, cat, center, type, id);

            // Output
            if (printPois && System.currentTimeMillis() > lastMillis + 40) {
                printPoisFound();
                lastMillis = System.currentTimeMillis();
            }

            // Write to file
            try {
                writer.write(poi.toCsv() + "\n");
            } catch (IOException e) {
                System.out.println("Error: Output file write error");
                System.exit(-1);
            }
        }
    });

    // Close writer
    try {
        writer.close();
    } catch (IOException e) {
        System.out.println("Error: Output file close error");
        System.exit(-1);
    }

    // Output results
    stopWatch.stop();

    printPoisFound();
    System.out.println();
    System.out.println("Elapsed time in milliseconds: " + stopWatch.getElapsedTime());

    // Quit
    System.exit(0);
}