List of usage examples for java.util Arrays asList
@SafeVarargs @SuppressWarnings("varargs") public static <T> List<T> asList(T... a)
From source file:ArraySet.java
public static void main(String args[]) { String elements[] = { "Java", "Source", "and", "Support", "." }; Set set = new ArraySet(Arrays.asList(elements)); Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); }// w w w. ja va2s . com }
From source file:org.mshariq.cxf.brave.Client.java
public static void main(String args[]) throws Exception { OkHttpSender sender = OkHttpSender.create("http://127.0.0.1:9411/api/v1/spans"); AsyncReporter<Span> reporter = AsyncReporter.builder(sender).build(); Brave brave = new Brave.Builder("clientNew").reporter(reporter).build(); final BraveClientProvider provider = new BraveClientProvider(brave); final Response response = WebClient.create("http://localhost:9000/catalog/2", Arrays.asList(provider)) .accept(MediaType.APPLICATION_JSON).get(); ApplicationContext appctxt = new ClassPathXmlApplicationContext( Client.class.getResource("/context-client.xml").toString()); System.out.println("Client ready..."); SampleInterface client = (SampleInterface) appctxt.getBean("sampleClient"); System.out.println(client.getItems(0)); response.close();// w ww .j a v a 2 s . c o m reporter.close(); sender.close(); // Thread.sleep(5 * 6000 * 1000); System.out.println("Server exiting"); System.exit(0); }
From source file:org.kuali.student.git.cleaner.RepositoryCleanerMain.java
/** * @param args/*from w w w . ja v a 2 s. co m*/ */ public static void main(String[] args) { if (args.length < 1) { log.error("USAGE: <module name> [module specific arguments]"); System.exit(-1); } try { ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( "RepositoryCleanerMain-applicationContext.xml"); applicationContext.registerShutdownHook(); String beanName = args[0]; RepositoryCleaner repoCleaner = (RepositoryCleaner) applicationContext.getBean(beanName); /* * Exclude the module name from the args sent to the module. */ repoCleaner.validateArgs(Arrays.asList(args).subList(1, args.length)); repoCleaner.execute(); } catch (Exception e) { log.error("unexpected exception", e); } }
From source file:com.google.demo.translate.Translator.java
public static void main(String[] args) { parseInputs();/*from ww w . j a v a 2 s . com*/ try { String headers = String.join(",", source, targets.stream().map(i -> i.toString()).collect(Collectors.joining(","))); Files.write(output, Arrays.asList(headers), UTF_8, APPEND, CREATE); List<String> texts = new ArrayList<>(); while (it.hasNext()) { texts.add(preTranslationParser(it.next())); if (texts.size() == 10 || !it.hasNext()) { translate(texts); texts = new ArrayList<>(); } } } catch (IOException e) { throw new RuntimeException(e); } finally { LineIterator.closeQuietly(it); } }
From source file:com.xandrev.altafitcalendargenerator.Main.java
public static void main(String[] args) { CalendarPrinter printer = new CalendarPrinter(); XLSExtractor extractor = new XLSExtractor(); if (args != null && args.length > 0) { try {/*from w w w.java 2 s.c om*/ Options opt = new Options(); opt.addOption("f", true, "Filepath of the XLS file"); opt.addOption("t", true, "Type name of activities"); opt.addOption("m", true, "Month index"); opt.addOption("o", true, "Output filename of the generated ICS"); BasicParser parser = new BasicParser(); CommandLine cliParser = parser.parse(opt, args); if (cliParser.hasOption("f")) { String fileName = cliParser.getOptionValue("f"); LOG.debug("File name to be imported: " + fileName); String activityNames = cliParser.getOptionValue("t"); LOG.debug("Activity type names: " + activityNames); ArrayList<String> nameList = new ArrayList<>(); String[] actNames = activityNames.split(","); if (actNames != null) { nameList.addAll(Arrays.asList(actNames)); } LOG.debug("Sucessfully activities parsed: " + nameList.size()); if (cliParser.hasOption("m")) { String monthIdx = cliParser.getOptionValue("m"); LOG.debug("Month index: " + monthIdx); int month = Integer.parseInt(monthIdx) - 1; if (cliParser.hasOption("o")) { String outputfilePath = cliParser.getOptionValue("o"); LOG.debug("Output file to be generated: " + monthIdx); LOG.debug("Starting to extract the spreadsheet"); HashMap<Integer, ArrayList<TimeTrack>> result = extractor.importExcelSheet(fileName); LOG.debug("Extracted the spreadsheet done"); LOG.debug("Starting the filter of the data"); HashMap<Date, String> cal = printer.getCalendaryByItem(result, nameList, month); LOG.debug("Finished the filter of the data"); LOG.debug("Creating the ics Calendar"); net.fortuna.ical4j.model.Calendar calendar = printer.createICSCalendar(cal); LOG.debug("Finished the ics Calendar"); LOG.debug("Printing the ICS file to: " + outputfilePath); printer.saveCalendar(calendar, outputfilePath); LOG.debug("Finished the ICS file to: " + outputfilePath); } } } } catch (ParseException ex) { LOG.error("Error parsing the argument list: ", ex); } } }
From source file:Employee.java
public static void main(String args[]) { Employee emps[] = { new Employee("Finance", "A"), new Employee("Finance", "B"), new Employee("Finance", "C"), new Employee("Engineering", "D"), new Employee("Engineering", "E"), new Employee("Engineering", "F"), new Employee("Sales", "G"), new Employee("Sales", "H"), new Employee("Support", "I"), }; Set set = new TreeSet(new EmpComparator()); set.addAll(Arrays.asList(emps)); System.out.println(set);/*w ww .ja va 2s . co m*/ }
From source file:Eon.java
public static void main(String... args) { try {//from w w w .j av a 2 s .co m Class<?> c = (args.length == 0 ? Eon.class : Class.forName(args[0])); out.format("Enum name: %s%nEnum constants: %s%n", c.getName(), Arrays.asList(c.getEnumConstants())); if (c == Eon.class) out.format(" Eon.values(): %s%n", Arrays.asList(Eon.values())); // production code should handle this exception more gracefully } catch (ClassNotFoundException x) { x.printStackTrace(); } }
From source file:com.tragicphantom.stdf.tools.extract.CommandLine.java
public static void main(String[] args) { try {//ww w. ja va2s. co m Options options = setupOptions(); org.apache.commons.cli.CommandLine cl = new GnuParser().parse(options, args); if (cl.hasOption("t")) { HashSet<String> types = new HashSet<String>(Arrays.asList(cl.getOptionValue("t").split(","))); OutputFormatter outputFormatter; if (cl.hasOption("x")) outputFormatter = new RawOutputFormatter(); else if (cl.hasOption("c")) outputFormatter = new CsvOutputFormatter(); else outputFormatter = new DefaultOutputFormatter(); for (String file : cl.getArgs()) { System.out.println(file); Visitor visitor = new Visitor(file, types); System.out.println(visitor.size() + " records found"); for (Record record : visitor) outputFormatter.write(record); } } else new HelpFormatter().printHelp("extract", options); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.ok2c.lightmtp.examples.MailUserAgentExample.java
public static void main(final String[] args) throws Exception { String text1 = "From: root\r\n" + "To: testuser1\r\n" + "Subject: test message 1\r\n" + "\r\n" + "This is a short test message 1\r\n"; String text2 = "From: root\r\n" + "To: testuser1, testuser2\r\n" + "Subject: test message 2\r\n" + "\r\n" + "This is a short test message 2\r\n"; String text3 = "From: root\r\n" + "To: testuser1, testuser2, testuser3\r\n" + "Subject: test message 3\r\n" + "\r\n" + "This is a short test message 3\r\n"; List<DeliveryRequest> requests = new ArrayList<DeliveryRequest>(); requests.add(new BasicDeliveryRequest("root", Arrays.asList("testuser1"), new ByteArraySource(text1.getBytes("US-ASCII")))); requests.add(new BasicDeliveryRequest("root", Arrays.asList("testuser1", "testuser2"), new ByteArraySource(text2.getBytes("US-ASCII")))); requests.add(new BasicDeliveryRequest("root", Arrays.asList("testuser1", "testuser2", "testuser3"), new ByteArraySource(text3.getBytes("US-ASCII")))); MailUserAgent mua = new DefaultMailUserAgent(TransportType.SMTP, IOReactorConfig.DEFAULT); mua.start();/*from w w w . j av a2 s. co m*/ try { InetSocketAddress address = new InetSocketAddress("localhost", 2525); Queue<Future<DeliveryResult>> queue = new LinkedList<Future<DeliveryResult>>(); for (DeliveryRequest request : requests) { queue.add(mua.deliver(new SessionEndpoint(address), 0, request, null)); } while (!queue.isEmpty()) { Future<DeliveryResult> future = queue.remove(); DeliveryResult result = future.get(); System.out.println("Delivery result: " + result); } } finally { mua.shutdown(); } }
From source file:com.cloud.test.longrun.PerformanceWithAPI.java
public static void main(String[] args) { List<String> argsList = Arrays.asList(args); Iterator<String> iter = argsList.iterator(); String host = "http://localhost"; int numThreads = 1; while (iter.hasNext()) { String arg = iter.next(); if (arg.equals("-h")) { host = "http://" + iter.next(); }//from w w w.j a v a2 s. c om if (arg.equals("-t")) { numThreads = Integer.parseInt(iter.next()); } if (arg.equals("-n")) { numVM = Integer.parseInt(iter.next()); } } final String server = host + ":" + _apiPort + "/"; final String developerServer = host + ":" + _developerPort + _apiUrl; s_logger.info("Starting test in " + numThreads + " thread(s). Each thread is launching " + numVM + " VMs"); for (int i = 0; i < numThreads; i++) { new Thread(new Runnable() { public void run() { try { String username = null; String singlePrivateIp = null; String singlePublicIp = null; Random ran = new Random(); username = Math.abs(ran.nextInt()) + "-user"; //Create User User myUser = new User(username, username, server, developerServer); try { myUser.launchUser(); myUser.registerUser(); } catch (Exception e) { s_logger.warn("Error code: ", e); } if (myUser.getUserId() != null) { s_logger.info("User " + myUser.getUserName() + " was created successfully, starting VM creation"); //create VMs for the user for (int i = 0; i < numVM; i++) { //Create a new VM, add it to the list of user's VMs VirtualMachine myVM = new VirtualMachine(myUser.getUserId()); myVM.deployVM(_zoneId, _serviceOfferingId, _templateId, myUser.getDeveloperServer(), myUser.getApiKey(), myUser.getSecretKey()); myUser.getVirtualMachines().add(myVM); singlePrivateIp = myVM.getPrivateIp(); if (singlePrivateIp != null) { s_logger.info( "VM with private Ip " + singlePrivateIp + " was successfully created"); } else { s_logger.info("Problems with VM creation for a user" + myUser.getUserName()); break; } //get public IP address for the User myUser.retrievePublicIp(_zoneId); singlePublicIp = myUser.getPublicIp().get(myUser.getPublicIp().size() - 1); if (singlePublicIp != null) { s_logger.info("Successfully got public Ip " + singlePublicIp + " for user " + myUser.getUserName()); } else { s_logger.info("Problems with getting public Ip address for user" + myUser.getUserName()); break; } //create ForwardProxy rules for user's VMs int responseCode = CreateForwardingRule(myUser, singlePrivateIp, singlePublicIp, "22", "22"); if (responseCode == 500) break; } s_logger.info("Deployment successful..." + numVM + " VMs were created. Waiting for 5 min before performance test"); Thread.sleep(300000L); // Wait //Start performance test for the user s_logger.info("Starting performance test for Guest network that has " + myUser.getPublicIp().size() + " public IP addresses"); for (int j = 0; j < myUser.getPublicIp().size(); j++) { s_logger.info("Starting test for user which has " + myUser.getVirtualMachines().size() + " vms. Public IP for the user is " + myUser.getPublicIp().get(j) + " , number of retries is " + _retry + " , private IP address of the machine is" + myUser.getVirtualMachines().get(j).getPrivateIp()); guestNetwork myNetwork = new guestNetwork(myUser.getPublicIp().get(j), _retry); myNetwork.setVirtualMachines(myUser.getVirtualMachines()); new Thread(myNetwork).start(); } } } catch (Exception e) { s_logger.error(e); } } }).start(); } }