List of usage examples for org.apache.commons.cli ParseException getMessage
public String getMessage()
From source file:com.twitter.heron.apiserver.Runtime.java
@SuppressWarnings({ "IllegalCatch", "RegexpSinglelineJava" }) public static void main(String[] args) throws Exception { final Options options = createOptions(); final Options helpOptions = constructHelpOptions(); CommandLineParser parser = new DefaultParser(); // parse the help options first. CommandLine cmd = parser.parse(helpOptions, args, true); if (cmd.hasOption(Flag.Help.name)) { usage(options);/*ww w. ja v a2s .com*/ return; } try { cmd = parser.parse(options, args); } catch (ParseException pe) { System.err.println(pe.getMessage()); usage(options); return; } final boolean verbose = isVerbose(cmd); // set and configure logging level Logging.setVerbose(verbose); Logging.configure(verbose); LOG.debug("apiserver overrides:\n {}", cmd.getOptionProperties(Flag.Property.name)); final String toolsHome = getToolsHome(); // read command line flags final String cluster = cmd.getOptionValue(Flag.Cluster.name); final String heronConfigurationDirectory = getConfigurationDirectory(toolsHome, cmd); final String heronDirectory = getHeronDirectory(cmd); final String releaseFile = getReleaseFile(toolsHome, cmd); final String configurationOverrides = loadOverrides(cmd); final int port = getPort(cmd); final String downloadHostName = getDownloadHostName(cmd); final String heronCorePackagePath = getHeronCorePackagePath(cmd); final Config baseConfiguration = ConfigUtils.getBaseConfiguration(heronDirectory, heronConfigurationDirectory, releaseFile, configurationOverrides); final ResourceConfig config = new ResourceConfig(Resources.get()); final Server server = new Server(port); final ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); contextHandler.setContextPath("/"); LOG.info("using configuration path: {}", heronConfigurationDirectory); contextHandler.setAttribute(HeronResource.ATTRIBUTE_CLUSTER, cluster); contextHandler.setAttribute(HeronResource.ATTRIBUTE_CONFIGURATION, baseConfiguration); contextHandler.setAttribute(HeronResource.ATTRIBUTE_CONFIGURATION_DIRECTORY, heronConfigurationDirectory); contextHandler.setAttribute(HeronResource.ATTRIBUTE_CONFIGURATION_OVERRIDE_PATH, configurationOverrides); contextHandler.setAttribute(HeronResource.ATTRIBUTE_PORT, String.valueOf(port)); contextHandler.setAttribute(HeronResource.ATTRIBUTE_DOWNLOAD_HOSTNAME, Utils.isNotEmpty(downloadHostName) ? String.valueOf(downloadHostName) : null); contextHandler.setAttribute(HeronResource.ATTRIBUTE_HERON_CORE_PACKAGE_PATH, Utils.isNotEmpty(heronCorePackagePath) ? String.valueOf(heronCorePackagePath) : null); server.setHandler(contextHandler); final ServletHolder apiServlet = new ServletHolder(new ServletContainer(config)); contextHandler.addServlet(apiServlet, API_BASE_PATH); try { server.start(); LOG.info("Heron apiserver started at {}", server.getURI()); server.join(); } catch (Exception ex) { final String message = getErrorMessage(server, port, ex); LOG.error(message); System.err.println(message); System.exit(1); } finally { server.destroy(); } }
From source file:com.zimbra.cs.store.file.BlobConsistencyUtil.java
public static void main(String[] args) { BlobConsistencyUtil app = new BlobConsistencyUtil(); try {//from w w w . ja va2 s . c o m app.parseArgs(args); } catch (ParseException e) { app.usage(e.getMessage()); } try { app.run(); } catch (Exception e) { if (app.verbose) { e.printStackTrace(new PrintWriter(System.err, true)); } else { String msg = e.getMessage(); if (msg == null) { msg = e.toString(); } System.err.println(msg); } System.exit(1); } }
From source file:com.mvdb.etl.actions.ModifyCustomerData.java
public static void main(String[] args) { ActionUtils.assertEnvironmentSetupOk(); ActionUtils.assertFileExists("~/.mvdb", "~/.mvdb missing. Existing."); ActionUtils.assertFileExists("~/.mvdb/status.InitCustomerData.complete", "300init-customer-data.sh not executed yet. Exiting"); //This check is not required as data can be modified any number of times //ActionUtils.assertFileDoesNotExist("~/.mvdb/status.ModifyCustomerData.complete", "ModifyCustomerData already done. Start with 100init.sh if required. Exiting"); ActionUtils.setUpInitFileProperty(); ActionUtils.createMarkerFile("~/.mvdb/status.ModifyCustomerData.start", true); String customerName = null;/*from w ww . j a va 2s . c om*/ //Date startDate = null; //Date endDate = null; final CommandLineParser cmdLinePosixParser = new PosixParser(); final Options posixOptions = constructPosixOptions(); CommandLine commandLine; try { commandLine = cmdLinePosixParser.parse(posixOptions, args); // if (commandLine.hasOption("startDate")) // { // String startDateStr = commandLine.getOptionValue("startDate"); // startDate = ActionUtils.getDate(startDateStr); // } // if (commandLine.hasOption("endDate")) // { // String endDateStr = commandLine.getOptionValue("endDate"); // endDate = ActionUtils.getDate(endDateStr); // } if (commandLine.hasOption("customerName")) { customerName = commandLine.getOptionValue("customerName"); } } catch (ParseException parseException) // checked exception { System.err.println( "Encountered exception while parsing using PosixParser:\n" + parseException.getMessage()); } if (customerName == null) { System.err.println("customerName has not been specified. Aborting..."); System.exit(1); } // if (startDate == null) // { // System.err.println("startDate has not been specified with the correct format YYYYMMddHHmmss. Aborting..."); // System.exit(1); // } // // if (endDate == null) // { // System.err.println("endDate has not been specified with the correct format YYYYMMddHHmmss. Aborting..."); // System.exit(1); // } // // if (endDate.after(startDate) == false) // { // System.err.println("endDate must be after startDate. Aborting..."); // System.exit(1); // } ApplicationContext context = Top.getContext(); final OrderDAO orderDAO = (OrderDAO) context.getBean("orderDAO"); long maxId = orderDAO.findMaxId(); long totalOrders = orderDAO.findTotalOrders(); long modifyCount = (long) (totalOrders * 0.1); String lastUsedEndTimeStr = ActionUtils.getConfigurationValue(customerName, ConfigurationKeys.LAST_USED_END_TIME); long lastUsedEndTime = Long.parseLong(lastUsedEndTimeStr); Date startDate1 = new Date(); startDate1.setTime(lastUsedEndTime + 1000 * 60 * 60 * 24 * 1); Date endDate1 = new Date(startDate1.getTime() + 1000 * 60 * 60 * 24 * 1); for (int i = 0; i < modifyCount; i++) { Date updateDate = RandomUtil.getRandomDateInRange(startDate1, endDate1); long orderId = (long) Math.floor((Math.random() * maxId)) + 1L; logger.info("Modify Id " + orderId + " in orders"); Order theOrder = orderDAO.findByOrderId(orderId); // System.out.println("theOrder : " + theOrder); theOrder.setNote(RandomUtil.getRandomString(4)); theOrder.setUpdateTime(updateDate); theOrder.setSaleCode(RandomUtil.getRandomInt()); orderDAO.update(theOrder); // System.out.println("theOrder Modified: " + theOrder); } ActionUtils.setConfigurationValue(customerName, ConfigurationKeys.LAST_USED_END_TIME, String.valueOf(endDate1.getTime())); logger.info("Modified " + modifyCount + " orders"); ActionUtils.createMarkerFile("~/.mvdb/status.ModifyCustomerData.complete", true); }
From source file:net.cliftonsnyder.svgchart.Main.java
public static void main(String[] args) { Options options = new Options(); options.addOption("c", "stylesheet", true, "CSS stylesheet (default: " + SVGChart.DEFAULT_STYLESHEET + ")"); options.addOption("h", "height", true, "chart height"); options.addOption("i", "input-file", true, "input file [default: stdin]"); options.addOption("o", "output-file", true, "output file [default: stdout]"); options.addOption("w", "width", true, "chart width"); options.addOption("?", "help", false, "print a brief help message"); Option type = new Option("t", "type", true, "chart type " + Arrays.toString(SVGChart.TYPES)); type.setRequired(true);//from w w w .j av a 2 s .c o m options.addOption(type); CommandLineParser parser = new GnuParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine line = null; try { // parse the command line arguments line = parser.parse(options, args); if (line.hasOption("help")) { formatter.printHelp(USAGE, options); System.exit(0); } } catch (ParseException exp) { // oops, something went wrong System.err.println("unable to parse command line: " + exp.getMessage()); formatter.printHelp(USAGE, options); System.exit(1); } SVGChart chart = null; String tmp = line.getOptionValue("type"); Matcher m = null; for (Pattern p : SVGChart.TYPE_PATTERNS) { if ((m = p.matcher(tmp)).matches()) { switch (m.group().charAt(0)) { case 'l': // DEBUG System.err.println("line"); break; case 'b': System.err.println("bar"); chart = new BarChart(); break; case 'p': System.err.println("pie"); break; default: System.err.println("unknown or unimplemented chart type: '" + tmp + "'"); System.exit(1); } } } try { chart.setWidth(Double.parseDouble(line.getOptionValue("width", "" + SVGChart.DEFAULT_WIDTH))); } catch (NumberFormatException e) { System.err.println( "unable to parse command line: invalid width value '" + line.getOptionValue("width") + "'"); System.exit(1); } try { chart.setHeight(Double.parseDouble(line.getOptionValue("height", "" + SVGChart.DEFAULT_HEIGHT))); } catch (NumberFormatException e) { System.err.println( "unable to parse command line: invalid height value '" + line.getOptionValue("height") + "'"); System.exit(1); } InputStream in = System.in; tmp = line.getOptionValue("input-file", "-"); if ("-".equals(tmp)) { in = System.in; } else { try { in = new FileInputStream(tmp); } catch (FileNotFoundException e) { System.err.println("input file not found: '" + tmp + "'"); System.exit(1); } } PrintStream out = System.out; tmp = line.getOptionValue("output-file", "-"); if ("-".equals(tmp)) { out = System.out; } else { try { out = new PrintStream(new FileOutputStream(tmp)); } catch (FileNotFoundException e) { System.err.println("output file not found: '" + tmp + "'"); System.exit(1); } } tmp = line.getOptionValue("stylesheet", SVGChart.DEFAULT_STYLESHEET); chart.setStyleSheet(tmp); try { chart.parseInput(in); } catch (IOException e) { System.err.println("I/O error while reading input"); System.exit(1); } catch (net.cliftonsnyder.svgchart.parse.ParseException e) { System.err.println("error parsing input: " + e.getMessage()); } chart.createChart(); try { chart.printChart(out, true); } catch (IOException e) { System.err.println("error serializing output"); System.exit(1); } }
From source file:de.topobyte.livecg.LiveCG.java
public static void main(String[] args) { // @formatter:off Options options = new Options(); OptionHelper.add(options, OPTION_CONFIG, true, false, "path", "config file"); // @formatter:on CommandLineParser clp = new GnuParser(); CommandLine line = null;/*from www. j a v a 2s. c om*/ try { line = clp.parse(options, args); } catch (ParseException e) { System.err.println("Parsing command line failed: " + e.getMessage()); new HelpFormatter().printHelp(HELP_MESSAGE, options); System.exit(1); } StringOption config = ArgumentHelper.getString(line, OPTION_CONFIG); if (config.hasValue()) { String configPath = config.getValue(); LiveConfig.setPath(configPath); } Configuration configuration = PreferenceManager.getConfiguration(); String lookAndFeel = configuration.getSelectedLookAndFeel(); if (lookAndFeel == null) { lookAndFeel = UIManager.getSystemLookAndFeelClassName(); } try { UIManager.setLookAndFeel(lookAndFeel); } catch (Exception e) { logger.error("error while setting look and feel '" + lookAndFeel + "': " + e.getClass().getSimpleName() + ", message: " + e.getMessage()); } Content content = null; String filename = "res/presets/Startup.geom"; String[] extra = line.getArgs(); if (extra.length > 0) { filename = extra[0]; } ContentReader reader = new ContentReader(); InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename); try { content = reader.read(input); } catch (Exception e) { logger.info("unable to load startup geometry file", e); logger.info("Exception: " + e.getClass().getSimpleName()); logger.info("Message: " + e.getMessage()); } final LiveCG runner = new LiveCG(); final Content c = content; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { runner.setup(true, c); } }); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { runner.frame.requestFocus(); } }); }
From source file:com.opengamma.integration.marketdata.WatchListRecorder.java
/** * Main entry point./* www .jav a 2s. c om*/ * * @param args the arguments * @throws Exception if an error occurs */ public static void main(final String[] args) throws Exception { // CSIGNORE final CommandLineParser parser = new PosixParser(); final Options options = new Options(); final Option outputFileOpt = new Option("o", "output", true, "output file"); outputFileOpt.setRequired(true); options.addOption(outputFileOpt); final Option urlOpt = new Option("u", "url", true, "server url"); options.addOption(urlOpt); String outputFile = "watchList.txt"; String url = "http://localhost:8080/jax"; try { final CommandLine cmd = parser.parse(options, args); outputFile = cmd.getOptionValue("output"); url = cmd.getOptionValue("url"); } catch (final ParseException exp) { s_logger.error("Option parsing failed: {}", exp.getMessage()); System.exit(0); } final WatchListRecorder recorder = create(URI.create(url), "main", "combined"); recorder.addWatchScheme(ExternalSchemes.BLOOMBERG_TICKER); recorder.addWatchScheme(ExternalSchemes.BLOOMBERG_BUID); final PrintWriter pw = new PrintWriter(outputFile); recorder.setPrintWriter(pw); recorder.run(); pw.close(); System.exit(0); }
From source file:com.rabbitmq.examples.PerfTest.java
public static void main(String[] args) { Options options = getOptions();//w ww . j ava2 s. c o m CommandLineParser parser = new GnuParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption('?')) { usage(options); System.exit(0); } String exchangeType = strArg(cmd, 't', "direct"); String exchangeName = strArg(cmd, 'e', exchangeType); String queueName = strArg(cmd, 'u', ""); String routingKey = strArg(cmd, 'k', null); boolean randomRoutingKey = cmd.hasOption('K'); int samplingInterval = intArg(cmd, 'i', 1); float producerRateLimit = floatArg(cmd, 'r', 0.0f); float consumerRateLimit = floatArg(cmd, 'R', 0.0f); int producerCount = intArg(cmd, 'x', 1); int consumerCount = intArg(cmd, 'y', 1); int producerTxSize = intArg(cmd, 'm', 0); int consumerTxSize = intArg(cmd, 'n', 0); long confirm = intArg(cmd, 'c', -1); boolean autoAck = cmd.hasOption('a'); int multiAckEvery = intArg(cmd, 'A', 0); int channelPrefetch = intArg(cmd, 'Q', 0); int consumerPrefetch = intArg(cmd, 'q', 0); int minMsgSize = intArg(cmd, 's', 0); int timeLimit = intArg(cmd, 'z', 0); int producerMsgCount = intArg(cmd, 'C', 0); int consumerMsgCount = intArg(cmd, 'D', 0); List<?> flags = lstArg(cmd, 'f'); int frameMax = intArg(cmd, 'M', 0); int heartbeat = intArg(cmd, 'b', 0); boolean predeclared = cmd.hasOption('p'); String uri = strArg(cmd, 'h', "amqp://localhost"); //setup PrintlnStats stats = new PrintlnStats(1000L * samplingInterval, producerCount > 0, consumerCount > 0, (flags.contains("mandatory") || flags.contains("immediate")), confirm != -1); ConnectionFactory factory = new ConnectionFactory(); factory.setShutdownTimeout(0); // So we still shut down even with slow consumers factory.setUri(uri); factory.setRequestedFrameMax(frameMax); factory.setRequestedHeartbeat(heartbeat); MulticastParams p = new MulticastParams(); p.setAutoAck(autoAck); p.setAutoDelete(true); p.setConfirm(confirm); p.setConsumerCount(consumerCount); p.setConsumerMsgCount(consumerMsgCount); p.setConsumerRateLimit(consumerRateLimit); p.setConsumerTxSize(consumerTxSize); p.setExchangeName(exchangeName); p.setExchangeType(exchangeType); p.setFlags(flags); p.setMultiAckEvery(multiAckEvery); p.setMinMsgSize(minMsgSize); p.setPredeclared(predeclared); p.setConsumerPrefetch(consumerPrefetch); p.setChannelPrefetch(channelPrefetch); p.setProducerCount(producerCount); p.setProducerMsgCount(producerMsgCount); p.setProducerTxSize(producerTxSize); p.setQueueName(queueName); p.setRoutingKey(routingKey); p.setRandomRoutingKey(randomRoutingKey); p.setProducerRateLimit(producerRateLimit); p.setTimeLimit(timeLimit); MulticastSet set = new MulticastSet(stats, factory, p); set.run(true); stats.printFinal(); } catch (ParseException exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); usage(options); } catch (Exception e) { System.err.println("Main thread caught exception: " + e); e.printStackTrace(); System.exit(1); } }
From source file:com.microsoft.kafkaavailability.App.java
public static void main(String[] args) throws IOException, MetaDataManagerException, InterruptedException { System.out.println("Starting KafkaAvailability Tool"); IPropertiesManager appPropertiesManager = new PropertiesManager<AppProperties>("appProperties.json", AppProperties.class); appProperties = (AppProperties) appPropertiesManager.getProperties(); Options options = new Options(); options.addOption("r", "run", true, "Number of runs. Don't use this argument if you want to run infintely."); options.addOption("s", "sleep", true, "Time (in milliseconds) to sleep between each run. Default is 300000"); Option clusterOption = Option.builder("c").hasArg().required(true).longOpt("cluster") .desc("(REQUIRED) Cluster name").build(); options.addOption(clusterOption);/* w w w . j ava 2 s .c o m*/ CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); try { // parse the command line arguments CommandLine line = parser.parse(options, args); int howManyRuns; m_cluster = line.getOptionValue("cluster"); MDC.put("cluster", m_cluster); if (line.hasOption("sleep")) { m_sleepTime = Integer.parseInt(line.getOptionValue("sleep")); } if (line.hasOption("run")) { howManyRuns = Integer.parseInt(line.getOptionValue("run")); for (int i = 0; i < howManyRuns; i++) { InitMetrics(); RunOnce(); Thread.sleep(m_sleepTime); } } else { while (true) { InitMetrics(); RunOnce(); Thread.sleep(m_sleepTime); } } } catch (ParseException exp) { // oops, something went wrong System.err.println("Parsing failed. Reason: " + exp.getMessage()); formatter.printHelp("KafkaAvailability", options); } }
From source file:com.act.lcms.db.analysis.FeedingAnalysis.java
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build());//from w w w .j av a 2 s . c o m } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } File lcmsDir = new File(cl.getOptionValue(OPTION_DIRECTORY)); if (!lcmsDir.isDirectory()) { System.err.format("File at %s is not a directory\n", lcmsDir.getAbsolutePath()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } try (DB db = DB.openDBFromCLI(cl)) { System.out.format("Loading/updating LCMS scan files into DB\n"); ScanFile.insertOrUpdateScanFilesInDirectory(db, lcmsDir); System.out.format("Running feeding analysis\n"); performFeedingAnalysis(db, cl.getOptionValue(OPTION_DIRECTORY), cl.getOptionValue(OPTION_ION_NAME), cl.getOptionValue(OPTION_SEARCH_MZ), cl.getOptionValue(OPTION_PLATE_BARCODE), cl.getOptionValue(OPTION_FEEDING_STRAIN_OR_CONSTRUCT), cl.getOptionValue(OPTION_FEEDING_EXTRACT), cl.getOptionValue(OPTION_FEEDING_FED_CHEMICAL), cl.getOptionValue(OPTION_OUTPUT_PREFIX), "pdf"); } }
From source file:ca.ualberta.exemplar.core.Exemplar.java
public static void main(String[] rawArgs) throws FileNotFoundException, UnsupportedEncodingException { CommandLineParser cli = new BasicParser(); Options options = new Options(); options.addOption("h", "help", false, "shows this message"); options.addOption("b", "benchmark", true, "expects input to be a benchmark file (type = binary | nary)"); options.addOption("p", "parser", true, "defines which parser to use (parser = stanford | malt)"); CommandLine line = null;//from www. ja v a 2 s .c o m try { line = cli.parse(options, rawArgs); } catch (ParseException exp) { System.err.println(exp.getMessage()); System.exit(1); } String[] args = line.getArgs(); String parserName = line.getOptionValue("parser", "malt"); if (line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("sh ./exemplar", options); System.exit(0); } if (args.length != 2) { System.out.println("error: exemplar requires an input file and output file."); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("sh ./exemplar <input> <output>", options); System.exit(0); } File input = new File(args[0]); File output = new File(args[1]); String benchmarkType = line.getOptionValue("benchmark", ""); if (!benchmarkType.isEmpty()) { if (benchmarkType.equals("binary")) { BenchmarkBinary evaluation = new BenchmarkBinary(input, output, parserName); evaluation.runAndTime(); System.exit(0); } else { if (benchmarkType.equals("nary")) { BenchmarkNary evaluation = new BenchmarkNary(input, output, parserName); evaluation.runAndTime(); System.exit(0); } else { System.out.println("error: benchmark option has to be either 'binary' or 'nary'."); System.exit(0); } } } Parser parser = null; if (parserName.equals("stanford")) { parser = new ParserStanford(); } else { if (parserName.equals("malt")) { parser = new ParserMalt(); } else { System.out.println(parserName + " is not a valid parser."); System.exit(0); } } System.out.println("Starting EXEMPLAR..."); RelationExtraction exemplar = null; try { exemplar = new RelationExtraction(parser); } catch (FileNotFoundException e) { e.printStackTrace(); } BlockingQueue<String> inputQueue = new ArrayBlockingQueue<String>(QUEUE_SIZE); PlainTextReader reader = null; reader = new PlainTextReader(inputQueue, input); Thread readerThread = new Thread(reader); readerThread.start(); PrintStream statementsOut = null; try { statementsOut = new PrintStream(output, "UTF-8"); } catch (FileNotFoundException e1) { e1.printStackTrace(); System.exit(0); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); System.exit(0); } statementsOut.println("Subjects\tRelation\tObjects\tNormalized Relation\tSentence"); while (true) { String doc = null; try { doc = inputQueue.take(); } catch (InterruptedException e) { e.printStackTrace(); } if (doc.isEmpty()) { break; } List<RelationInstance> instances = exemplar.extractRelations(doc); for (RelationInstance instance : instances) { // Output SUBJ arguments in a separate field, for clarity boolean first = true; for (Argument arg : instance.getArguments()) { if (arg.argumentType.equals("SUBJ")) { if (first) { first = false; } else { statementsOut.print(",,"); } statementsOut.print(arg.argumentType + ":" + arg.entityId); } } // Output the original relation statementsOut.print("\t" + instance.getOriginalRelation() + "\t"); // Output the DOBJ arguments, followed by POBJ first = true; for (Argument arg : instance.getArguments()) { if (arg.argumentType.equals("DOBJ")) { if (first) { first = false; } else { statementsOut.print(",,"); } statementsOut.print(arg.argumentType + ":" + arg.entityId); } } for (Argument arg : instance.getArguments()) { if (arg.argumentType.startsWith("POBJ")) { if (first) { first = false; } else { statementsOut.print(",,"); } statementsOut.print(arg.argumentType + ":" + arg.entityId); } } statementsOut.print("\t" + instance.getNormalizedRelation()); statementsOut.print("\t" + instance.getSentence()); statementsOut.println(); } } System.out.println("Done!"); statementsOut.close(); }