List of usage examples for java.util Arrays asList
@SafeVarargs @SuppressWarnings("varargs") public static <T> List<T> asList(T... a)
From source file:JAXBTest.java
public static void main(String[] args) throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(Root.class); Root root = new Root(); Person fred = new Person(); fred.setName("Fred"); root.setFriend(Arrays.asList(fred)); Thing xbox = new Thing(); xbox.setDescription("Xbox 360"); root.setStuff(Arrays.asList(xbox)); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(root, System.out); }
From source file:edu.scripps.fl.pubchem.app.RelatedCurveProcessor.java
public static void main(String[] args) throws Exception { CommandLineHandler clh = new CommandLineHandler(); args = clh.handle(args);//from w w w. j a va 2s.c o m Integer[] list = (Integer[]) ConvertUtils.convert(args, Integer[].class); Integer referenceAid = list[0]; Integer[] relatedAids = new Integer[list.length - 1]; System.arraycopy(list, 1, relatedAids, 0, list.length - 1); URL url = PipelineUtils.class.getClassLoader() .getResource("edu/scripps/fl/pubchem/RelatedCurvesPipeline.xml"); Pipeline pipeline = new PipelineUtils().createPipeline(url, Arrays.asList(relatedAids)); List<Stage> stages = pipeline.getStages(); BeanUtils.setProperty(stages.get(1), "referenceAID", referenceAid); pipeline.run(); new PipelineUtils().logErrors(pipeline); }
From source file:com.rcaspar.fitbitbat.App.java
/** * Program entry point.// www. j av a 2 s .c o m * * @param args CLI args */ public static void main(final String[] args) { log.debug("main() - args={}", Arrays.asList(args)); final Args arguments = new Args(); try { new JCommander(arguments, args); final GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext( "classpath:application-context.xml"); applicationContext.registerShutdownHook(); applicationContext.start(); final Package appPackage = App.class.getPackage(); log.info("=== {} v.{} started ===", appPackage.getImplementationTitle(), appPackage.getImplementationVersion()); final FitBitBat fitBitBat = applicationContext.getBean(FitBitBat.class); if (fitBitBat.checkCredentials(arguments.getPin())) { fitBitBat.startAsync(); } else { log.error("Bad pin: {}", arguments.getPin()); } } catch (final OAuthException ex) { System.err.println(ex.getMessage()); System.exit(1); } catch (final ParameterException ex) { new JCommander(arguments).usage(); System.exit(-1); } catch (final Exception ex) { log.error("Cannot startup", ex); System.exit(-2); } }
From source file:ProducerAndConsumerTool.java
public static void main(String[] args) { ConsumerTool consumerTool = new ConsumerTool(); String[] unknown = CommandLineSupport.setOptions(consumerTool, args); HashSet<String> set1 = new HashSet<String>(Arrays.asList(unknown)); HashSet<String> set4 = new HashSet<String>(5); ProducerTool producerTool = new ProducerTool(); unknown = CommandLineSupport.setOptions(producerTool, args); HashSet<String> set2 = new HashSet<String>(Arrays.asList(unknown)); set1.retainAll(set2);// w ww . j a v a 2 s.co m if (set1.size() > 0) { System.out.println("Unknown options: " + set1); System.exit(-1); } /* consumerTool.run(); */ producerTool.run(); }
From source file:hd3gtv.tools.Hexview.java
public static void main(String[] args) throws IOException { if (args.length == 0) { System.err.println("Usage file1.ext file2.ext ..."); System.exit(1);/*from ww w .j av a 2 s . com*/ } Arrays.asList(args).forEach(f -> { try { File file = new File(f); InputStream in = new BufferedInputStream(new FileInputStream(file), 0xFFFF); byte[] buffer = new byte[COLS * ROWS]; int len; Hexview hv = null; while ((len = in.read(buffer)) != -1) { if (hv == null) { hv = new Hexview(buffer, 0, len); hv.setSize(file.length()); } else { hv.update(buffer, 0, len); } System.out.println(hv.getView()); } IOUtils.closeQuietly(in); } catch (Exception e) { e.printStackTrace(); System.exit(2); } }); }
From source file:de.thomasvolk.genexample.GenAlg.java
public static void main(String[] args) throws IOException, ParseException { System.out.println("Genetische Algorithmen"); Options options = new Options(); options.addOption(option("s", "Jede s Generation wird im Bericht ausgegeben")); options.addOption(option("w", "Quelldatei Wagon")); options.addOption(option("l", "Quelldatei Passagierliste")); options.addOption(option("d", "Zielverzeichnis Bericht")); options.addOption(option("a", "Algorithmus Typ " + Arrays.asList(AlgorithmusTyp.values()).toString())); options.addOption(option("g", "Anzahl der Generationen")); options.addOption(option("p", "Anzahl der Populationen")); options.addOption("h", false, "Hilfe"); CommandLineParser parser = new PosixParser(); try {/* w ww. j a va 2 s.c o m*/ CommandLine cmd = parser.parse(options, args); if (cmd.hasOption('h')) { printUsage(options); System.exit(0); } int generationen = getNummer(options, cmd.getOptionValue('g'), 2000); int populationen = getNummer(options, cmd.getOptionValue('p'), 20); int schritte = getNummer(options, cmd.getOptionValue('s'), 100); AlgorithmusTyp[] alg = AlgorithmusTyp.values(); if (cmd.hasOption('a')) { try { alg = new AlgorithmusTyp[] { AlgorithmusTyp.valueOf(cmd.getOptionValue('a')) }; } catch (IllegalArgumentException e) { printErrorAndExit(e, options); } } String reportDir = cmd.getOptionValue('d'); reportDir = StringUtils.isBlank(reportDir) ? "report" : reportDir; String wagonDatei = cmd.getOptionValue('w'); String passagierDatei = cmd.getOptionValue('l'); if (wagonDatei == null) { wagonDatei = erzeugeBeispielDatei("wagon.txt"); } if (passagierDatei == null) { passagierDatei = erzeugeBeispielDatei("passagiere.csv"); } System.out.println("Wagon Datein: " + wagonDatei); System.out.println("Passagier Datei: " + passagierDatei); System.out.println("Bericht: " + new File(reportDir).getAbsolutePath()); System.out.println("Anzahl Generationen: " + generationen); System.out.println("Anzahl Populationen: " + populationen); System.out.printf("Protokolliere jede %dte Generation im Bericht\n", schritte); WagonFactory wagonFactory = new WagonFactory(); PassagierFactory passagierFactory = new CSVPassagierFactory(); GenAlg genAlg = new GenAlg(wagonFactory, passagierFactory); genAlg.run(alg, passagierDatei, wagonDatei, reportDir, schritte, generationen, populationen); } catch (ParseException e) { printErrorAndExit(e, options); } }
From source file:Shuffle.java
public static void main(String[] args) { List<String> list = Arrays.asList(args); Collections.shuffle(list);/*from ww w . j a va2s . c o m*/ System.out.println(list); }
From source file:Ran.java
public static void main(String[] args) { // Get and shuffle the list of arguments List<String> argList = Arrays.asList(args); Collections.shuffle(argList); // Print out the elements using JDK 8 Streams argList.stream().forEach(e -> System.out.format("%s ", e)); // Print out the elements using for-each for (String arg : argList) { System.out.format("%s ", arg); }/* w w w .jav a 2 s.c om*/ System.out.println(); }
From source file:ArraySet.java
public static void main(String args[]) { String elements[] = { "A", "B", "C", "D", "E" }; Set set = new ArraySet(Arrays.asList(elements)); Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); }//from w w w . j a va 2 s .c om }
From source file:core.commonapp.server.data.CreateRequiredData.java
/** * @param args */ public static void main(String[] args) { new CreateRequiredData().storeData(Arrays.asList(args)); }