The main method.

@param args the arguments
@throws InterruptedException the interrupted exception
188673
public static void main(String[] args) throws InterruptedException, FileNotFoundException {
    SpeechToText service = new SpeechToText();
    IamOptions options = new IamOptions.Builder()
        .apiKey("<iam_api_key>")
        .build();
    service.setIamCredentials(options);

    // Create language model
    CreateLanguageModelOptions createOptions = new CreateLanguageModelOptions.Builder()
        .name("IEEE-permanent")
        .baseModelName("en-US_BroadbandModel")
        .description("My customization")
        .build();
    LanguageModel myModel = service.createLanguageModel(createOptions).execute().getResult();
    String id = myModel.getCustomizationId();

    try {
      // Add a corpus file to the model
      AddCorpusOptions addOptions = new AddCorpusOptions.Builder()
          .customizationId(id)
          .corpusName("corpus-1")
          .corpusFile(new File(CORPUS_FILE))
          .corpusFileContentType(HttpMediaType.TEXT_PLAIN)
          .allowOverwrite(false)
          .build();
      service.addCorpus(addOptions).execute();

      // Get corpus status
      GetCorpusOptions getOptions = new GetCorpusOptions.Builder()
          .customizationId(id)
          .corpusName("corpus-1")
          .build();
      for (
          int x = 0; x < 30
          && (service.getCorpus(getOptions).execute().getResult()).getStatus() != Corpus.Status.ANALYZED; x++
      ) {
        Thread.sleep(5000);
      }

      // Get all corpora
      ListCorporaOptions listCorporaOptions = new ListCorporaOptions.Builder()
          .customizationId(id)
          .build();
      Corpora corpora = service.listCorpora(listCorporaOptions).execute().getResult();
      System.out.println(corpora);

      // Get specific corpus
      Corpus corpus = service.getCorpus(getOptions).execute().getResult();
      System.out.println(corpus);

      // Now add some user words to the custom model
      service.addWord(new AddWordOptions.Builder()
          .customizationId(id)
          .wordName("IEEE")
          .word("IEEE")
          .displayAs("IEEE")
          .addSoundsLike("I. triple E.")
          .build()).execute();
      service.addWord(new AddWordOptions.Builder()
          .customizationId(id)
          .wordName("hhonors")
          .word("hhonors")
          .displayAs("IEEE")
          .addSoundsLike("H. honors")
          .addSoundsLike("Hilton honors")
          .build()).execute();

      // Display all words in the words resource (OOVs from the corpus and
      // new words just added) in ascending alphabetical order
      ListWordsOptions listWordsAlphabeticalOptions = new ListWordsOptions.Builder()
          .customizationId(id)
          .wordType(ListWordsOptions.WordType.ALL)
          .build();
      Words words = service.listWords(listWordsAlphabeticalOptions).execute().getResult();
      System.out.println("\nASCENDING ALPHABETICAL ORDER:");
      System.out.println(words);

      // Then display all words in the words resource in descending order
      // by count
      ListWordsOptions listWordsCountOptions = new ListWordsOptions.Builder()
          .customizationId(id)
          .wordType(ListWordsOptions.WordType.ALL)
          .sort("-" + ListWordsOptions.Sort.COUNT)
          .build();
      words = service.listWords(listWordsCountOptions).execute().getResult();
      System.out.println("\nDESCENDING ORDER BY COUNT:");
      System.out.println(words);

      // Now start training of the model
      TrainLanguageModelOptions trainOptions = new TrainLanguageModelOptions.Builder()
          .customizationId(id)
          .wordTypeToAdd(TrainLanguageModelOptions.WordTypeToAdd.ALL)
          .build();
      service.trainLanguageModel(trainOptions).execute();

      for (int x = 0; x < 30 && myModel.getStatus() != LanguageModel.Status.AVAILABLE; x++) {
        GetLanguageModelOptions getLanguageModelOptions = new GetLanguageModelOptions.Builder()
            .customizationId(id)
            .build();
        myModel = service.getLanguageModel(getLanguageModelOptions).execute().getResult();
        Thread.sleep(10000);
      }

      File audio = new File(AUDIO_FILE);
      RecognizeOptions recognizeOptionsWithModel = new RecognizeOptions.Builder()
          .model(RecognizeOptions.Model.EN_US_BROADBANDMODEL)
          .customizationId(id)
          .audio(audio)
          .contentType(HttpMediaType.AUDIO_WAV)
          .build();
      RecognizeOptions recognizeOptionsWithoutModel = new RecognizeOptions.Builder()
          .model(RecognizeOptions.Model.EN_US_BROADBANDMODEL)
          .audio(audio)
          .contentType(HttpMediaType.AUDIO_WAV)
          .build();

      // First decode WITHOUT the custom model
      SpeechRecognitionResults transcript = service.recognize(recognizeOptionsWithoutModel).execute().getResult();
      System.out.println(transcript);

      // Now decode with the custom model
      transcript = service.recognize(recognizeOptionsWithModel).execute().getResult();
      System.out.println(transcript);
    } finally {
      DeleteLanguageModelOptions deleteOptions = new DeleteLanguageModelOptions.Builder()
          .customizationId(id)
          .build();
      service.deleteLanguageModel(deleteOptions).execute();
    }

  }
336807
public static void main(String[] args) {
    try {
      System.exit( ToolRunner.run(null, new Balancer(), args) );
    } catch (Throwable e) {
      LOG.error(StringUtils.stringifyException(e));
      System.exit(-1);
    }

  }
989366
public static void main(String[] args) {
    org.apache.commons.cli.Options cliOptions = createCliOptions();
    try {
      CommandLine cli = parseCli(args, cliOptions);
      Options options = loadOptions(cli);
      validate(options);
      ConstraintParser parser = new ConstraintParser(options);
      try {
        output(parser, options.getOutputFile());
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    } catch (IncompleteCliException e) {
      // If the command line is not complete just print usage and help
      printErrorWithUsageAndHelp(cliOptions);
    }
  }
1020283
public static void main(String[] args) throws TimeoutException, InterruptedException {
    //#thriftserverapi
    Hello.FutureIface impl = new HelloImpl();
    ListeningServer server = Thrift.server().serveIface("localhost:8080", impl);
    Await.ready(server);
    //#thriftserverapi
  }
131921
public static void main(final String... args) throws Exception {
        try (ConfigurableApplicationContext context = SpringApplication.run(Application.class, args)) {
            log.info("Arguments: {}", Arrays.asList(args));

            try {
                context.getBean(Application.class).run(context);
            } catch (Exception e) {
                log.error("Exception in command execution", e);
            }
        }
    }
1109288
public static void main(String[] args) throws IOException, InterruptedException {

        // read the options
        Properties opt = readOptions(args);
        if (opt == null)
            throw new RuntimeException("Unable to find options file path, it must be provided as an argument to the call.");

        // validate the options
        if (opt.getProperty(_OPTION_INPUT_FOLDER) == null || opt.getProperty(_OPTION_INPUT_FOLDER).isEmpty())
            throw new RuntimeException("Option " + _OPTION_INPUT_FOLDER + " is required.");
        File inputDir = new File(opt.getProperty(_OPTION_INPUT_FOLDER));
        if (!inputDir.exists())
            throw new RuntimeException("Invalid input folder.");
        Pattern incRegex = opt.getProperty(_OPTION_INPUT_REGEX_INCLUDE) == null ? null : Pattern.compile(opt.getProperty(_OPTION_INPUT_REGEX_INCLUDE));
        Pattern excRegex = opt.getProperty(_OPTION_INPUT_REGEX_EXCLUDE) == null ? null : Pattern.compile(opt.getProperty(_OPTION_INPUT_REGEX_EXCLUDE));
        String mode = opt.getProperty(_OPTION_PROCESSING_MODE);
        if (mode == null)
            throw new RuntimeException("Option " + _OPTION_PROCESSING_MODE + " is required.");
        if (!"flat-to-xml".equals(mode) && !"xml-to-flat".equals(mode))
            throw new RuntimeException("Invalid mode (must be flat-to-xml or xml-to-flat).");
        String rawErrorCodes = opt.getProperty(_OPTION_PROCESSING_ERROR_CODES);
        List<String> errorCodes = null;
        if (rawErrorCodes != null && !rawErrorCodes.isEmpty()) {
            errorCodes = new ArrayList<>();
            for (String s : StringUtils.split(rawErrorCodes, ','))
                errorCodes.add(s.trim());
        }
        int numThreads = Math.min(Runtime.getRuntime().availableProcessors() + 1, 5);
        if (opt.getProperty(_OPTION_PROCESSING_NUM_THREADS) != null && !opt.getProperty(_OPTION_PROCESSING_NUM_THREADS).isEmpty())
            numThreads = Integer.parseInt(opt.getProperty(_OPTION_PROCESSING_NUM_THREADS));
        if (opt.getProperty(_OPTION_OUTPUT_FOLDER) == null || opt.getProperty(_OPTION_OUTPUT_FOLDER).isEmpty())
            throw new RuntimeException("Option " + _OPTION_OUTPUT_FOLDER + " is required.");
        String compression = opt.getProperty(_OPTION_PROCESSING_COMPRESSION);
        if (compression != null && !compression.equals("gz") && !compression.equals("xz") && !compression.equals("none") && !compression.equals("as-input"))
            throw new RuntimeException("Invalid compression (must be gz, xz, none, or as-input).");
        File outputDir = new File(opt.getProperty(_OPTION_OUTPUT_FOLDER));
        if (!outputDir.exists())
            throw new RuntimeException("Invalid outupt folder.");
        boolean cleanCreatedFiles = opt.getProperty(_OPTION_OUTPUT_CLEAN_CREATED_FILES) == null ? false : Boolean.valueOf(opt.getProperty(_OPTION_OUTPUT_CLEAN_CREATED_FILES));
        boolean createReport = opt.getProperty(_OPTION_OUTPUT_CREATE_REPORT) == null ? false : Boolean.valueOf(opt.getProperty(_OPTION_OUTPUT_CREATE_REPORT));
        String reportName = opt.getProperty(_OPTION_OUTPUT_REPORT_NAME) == null ? "report.txt" : opt.getProperty(_OPTION_OUTPUT_REPORT_NAME);
        boolean deidentify = opt.getProperty(_OPTION_OUTPUT_DEIDENTIFY_FILES) == null ? false : Boolean.valueOf(opt.getProperty(_OPTION_OUTPUT_DEIDENTIFY_FILES));

        // gather the files to process
        List<File> toProcess = new ArrayList<>();
        File[] files = inputDir.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isDirectory())
                    continue;
                boolean add = true;
                if (incRegex != null || excRegex != null) {
                    if (incRegex != null && !incRegex.matcher(file.getName()).matches())
                        add = false;
                    if (excRegex != null && excRegex.matcher(file.getName()).matches())
                        add = false;
                }
                if (add)
                    toProcess.add(file);
            }
        }

        // we will report the information in this collection
        Map<String, List<String>> reportData = new TreeMap<>();
        Map<String, AtomicInteger> globalCounts = new HashMap<>();
        Map<String, Set<String>> globalDetails = new HashMap<>();
        AtomicInteger globalTumorCount = new AtomicInteger();

        // create the work
        long start = System.currentTimeMillis();
        ExecutorService executor = Executors.newFixedThreadPool(numThreads);
        for (File inputFile : toProcess) {
            String outputFilename = invertFilename(inputFile, compression);
            @SuppressWarnings("ConstantConditions")
            File outputFile = new File(outputDir, outputFilename);
            if (inputFile.equals(outputFile))
                throw new RuntimeException("Was about to write output file into the input file, this can't be good!");
            if (cleanCreatedFiles)
                outputFile.deleteOnExit();
            List<String> data = new ArrayList<>();
            reportData.put(inputFile.getName(), data);
            executor.execute(new FileProcessor(inputFile, outputFile, data, cleanCreatedFiles, "flat-to-xml".equals(mode), globalCounts, globalDetails, globalTumorCount, errorCodes));
        }
        executor.shutdown();

        // wait for the work to be completed
        executor.awaitTermination(1, TimeUnit.DAYS);

        // write the report
        if (createReport) {
            Writer reportWriter = new OutputStreamWriter(new FileOutputStream(new File(outputDir, reportName)), StandardCharsets.UTF_8);

            reportWriter.write("Report created on " + new Date() + "\n\n");
            reportWriter.write("total number of files: " + formatNumber(toProcess.size()) + "\n");
            reportWriter.write("total processing time: " + formatTime(System.currentTimeMillis() - start) + "\n");
            reportWriter.write("total number of processed tumors: " + formatNumber(globalTumorCount.get()) + "\n");
            reportWriter.write("combined warnings:\n");

            int globalCount = 0;
            for (String code : NaaccrErrorUtils.getAllValidationErrors().keySet()) {
                if (errorCodes != null && !errorCodes.contains(code))
                    continue;
                int count = globalCounts.containsKey(code) ? globalCounts.get(code).get() : 0;
                if (count > 0) {
                    reportWriter.write("      " + code + ": " + formatNumber(count) + " cases\n");
                    if (globalDetails.containsKey(code)) {
                        List<String> list = new ArrayList<>(globalDetails.get(code));
                        Collections.sort(list);
                        reportWriter.write("         involved item(s): " + list.size() + " " + list + "\n");
                    }
                }
                globalCount += count;
            }
            if (globalCount == 0)
                reportWriter.write("      no warning found\n");

            for (Entry<String, List<String>> entry : reportData.entrySet()) {
                reportWriter.write("\n\n");
                reportWriter.write(deidentify ? "<de-identified file name>" : entry.getKey());
                reportWriter.write("\n");
                for (String line : entry.getValue()) {
                    reportWriter.write(line);
                    reportWriter.write("\n");
                }
            }
            reportWriter.close();
        }
    }
170772
public static void main(final String[] args) throws IOException
    {
        // This is just a _hack_ ...
        BufferedReader reader = null;
        if (args.length == 0)
        {
            System.err.println("No input file specified.");
            System.exit(-1);
        }
        if (args.length > 1)
        {
            reader = new BufferedReader(new InputStreamReader(new FileInputStream(args[1]), "UTF-8"));
            String line = reader.readLine();
            while (line != null && !line.startsWith("<!-- ###"))
            {
                System.out.println(line);
                line = reader.readLine();
            }
        }
        System.out.println(Processor.process(new File(args[0])));
        if (args.length > 1 && reader != null)
        {
            String line = reader.readLine();
            while (line != null)
            {
                System.out.println(line);
                line = reader.readLine();
            }
            reader.close();
        }
    }
451700
public static void main(String[] args) throws InterruptedException {
		System.out.println("Going to run 1s sleep in " + THREADS + " threads...");
		Split realTimeSplit = Split.start();
		for (int i = 0; i < THREADS; i++) {
			new MultithreadedSleeping().start();
		}
		// here we wait for all threads to end
		latch.await();
		System.out.println("Simon: " + SimonManager.getStopwatch(NAME));
		System.out.println("Real time: " + realTimeSplit.stop());
	}
703402
public static void main(String[] args) {
		Test instance = JKFactory.instance(Test.class);
		System.out.println(instance.hello());
		System.out.println(instance.hello());
		System.out.println(instance.hello());
		System.out.println(instance.hello());

	}
398406
public static void main(String[] args) {
        int exitCode = 0;
        final App app = new App();
        exitCode = app.run(args);
        LOGGER.debug("Exit code: {}", exitCode);
        System.exit(exitCode);
    }
722937
public static void main(String[] args) {
		Stopwatch stopwatch = SimonManager.getStopwatch("org.javasimon.examples.HelloWorld-stopwatch");

		Split split = stopwatch.start();
		System.out.println("Hello world, " + stopwatch);
		split.stop();

		// or this way using try-with-resource construction
		try (Split ignored = stopwatch.start()){
			System.out.println("Hello world (try-with-resource), " + stopwatch);
		}

		System.out.println("Result: " + stopwatch);
	}
102892
public static void main(String[] args) {
		PrintStream out = System.out;
		if (args.length > 0) {
			try {
				out = new PrintStream(new File(args[0]));
			} catch (FileNotFoundException e) {
				System.out.printf(ERR_FILE, args[0]);
			}
		}
		MBeanScanner mBeanScanner = new MBeanScanner();
		List<Config> configs = mBeanScanner.scan();
		ConfigWriter cw;
		cw = new ConfigWriter(out, configs);
		cw.write();
	}
145844
public static void main(String[] args)
	{
	   
		try
		{
			RMI.startRmiRegistry(Integer.parseInt(args[0]));
			System.in.read();
		}
		catch (Exception e)
		{
		
			e.printStackTrace();
		}
	}
243019
public static void main(String[] args) throws Exception {
      Shell shell = new ShellImpl();
      shell.init(args);
      shell.run();
      System.exit(0);
   }
194598
public static void main(String[] args) {
        DirectoryIterator iter = new DirectoryIterator(args);
        while(iter.hasNext())
            System.out.println(iter.next().getAbsolutePath());
    }
945508
public static void main(final String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                Utils4Swing.initSystemLookAndFeel();
                Utils4Swing.createShowAndPosition("Test Progress Dialog",
                        new FileCopyProgressPanel(), true, new ScreenCenterPositioner());
            }
        });
    }
65375
public static void main(final String[] args) {
        try {
            new Main().run(args);
        } catch (final JBakeException e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(1);
        } catch (final Throwable e) {
            System.err.println("An unexpected error occurred: " + e.getMessage());
            e.printStackTrace();
            System.exit(2);
        }
    }