List of usage examples for java.util Arrays asList
@SafeVarargs @SuppressWarnings("varargs") public static <T> List<T> asList(T... a)
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)); ProducerTool producerTool = new ProducerTool(); unknown = CommandLineSupport.setOptions(producerTool, args); HashSet<String> set2 = new HashSet<String>(Arrays.asList(unknown)); set1.retainAll(set2);// w w w. ja v a 2 s . c om if (set1.size() > 0) { System.out.println("Unknown options: " + set1); System.exit(-1); } consumerTool.run(); producerTool.run(); }
From source file:com.apress.prospringintegration.messagestore.jdbc.JdbcTest.java
public static void main(String[] args) throws Throwable { ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext( "classpath:spring/jdbc/spring-context.xml"); MessageProducer messageProducer = classPathXmlApplicationContext.getBean(MessageProducer.class); for (int i = 0; i < 10; i++) messageProducer.sendMessages(i,//from w w w .j a v a2 s . c o m Arrays.asList(new String[] { "apple", "banana", "carrot", "date", "egg" })); Thread.sleep(1000 * 10); }
From source file:com.apress.prospringintegration.messagestore.gemfire.GemfireTest.java
public static void main(String[] args) throws Throwable { ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext( "classpath:spring/gemfire/spring-context.xml"); MessageProducer messageProducer = classPathXmlApplicationContext.getBean(MessageProducer.class); for (int i = 0; i < 10; i++) messageProducer.sendMessages(i,/*w w w . j a v a 2 s. c o m*/ Arrays.asList(new String[] { "apple", "banana", "carrot", "date", "egg" })); Thread.sleep(1000 * 10); }
From source file:abs.backend.erlang.ErlangBackend.java
public static void main(final String... args) { try {//from ww w . ja v a 2 s .c om new ErlangBackend().compile(args); } catch (InternalBackendException e) { System.err.println(e.getMessage()); System.exit(1); } catch (NotImplementedYetException e) { System.err.println(e.getMessage()); System.exit(0); } catch (Exception e) { System.err.println("An error occurred during compilation:\n" + e.getMessage()); if (Arrays.asList(args).contains("-debug")) { e.printStackTrace(); } System.exit(1); } }
From source file:CompileSourceInMemory.java
public static void main(String args[]) throws IOException { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>(); StringWriter writer = new StringWriter(); PrintWriter out = new PrintWriter(writer); out.println("public class HelloWorld {"); out.println(" public static void main(String args[]) {"); out.println(" System.out.println(\"This is in another java file\");"); out.println(" }"); out.println("}"); out.close();// w w w. j ava 2 s . c o m JavaFileObject file = new JavaSourceFromString("HelloWorld", writer.toString()); Iterable<? extends JavaFileObject> compilationUnits = Arrays.asList(file); CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, compilationUnits); boolean success = task.call(); for (Diagnostic diagnostic : diagnostics.getDiagnostics()) { System.out.println(diagnostic.getCode()); System.out.println(diagnostic.getKind()); System.out.println(diagnostic.getPosition()); System.out.println(diagnostic.getStartPosition()); System.out.println(diagnostic.getEndPosition()); System.out.println(diagnostic.getSource()); System.out.println(diagnostic.getMessage(null)); } System.out.println("Success: " + success); if (success) { try { Class.forName("HelloWorld").getDeclaredMethod("main", new Class[] { String[].class }).invoke(null, new Object[] { null }); } catch (ClassNotFoundException e) { System.err.println("Class not found: " + e); } catch (NoSuchMethodException e) { System.err.println("No such method: " + e); } catch (IllegalAccessException e) { System.err.println("Illegal access: " + e); } catch (InvocationTargetException e) { System.err.println("Invocation target: " + e); } } }
From source file:edu.illinois.cs.cogcomp.wikifier.utils.freebase.cleanDL.java
public static void main(String[] args) throws IOException { List<String> lines = FileUtils.readLines(new File("/Users/Shyam/mention.eval.dl")); for (String line : lines) { String[] parts = line.split("\\s+"); System.out.println(parts[0] + parts[1] + parts[2]); StringBuilder sb = new StringBuilder(); for (int i = 3; i < parts.length; i++) sb.append(parts[i] + " "); if (mentionFilter(parts)) { System.out.println("removing " + Arrays.asList(parts)); continue; }//w ww.j a va 2s . c om if (mentions.containsKey(parts[0])) { mentions.get(parts[0]).add(new DocMention(parts[0], sb.toString(), Integer.parseInt(parts[1]), Integer.parseInt(parts[2]))); } else { mentions.put(parts[0], new ArrayList<DocMention>()); mentions.get(parts[0]).add(new DocMention(parts[0], sb.toString(), Integer.parseInt(parts[1]), Integer.parseInt(parts[2]))); } } for (String doc : mentions.keySet()) { handleDoc(mentions.get(doc)); } outputMentions(); }
From source file:com.rk.grid.cluster.slave.NodeMain.java
@SuppressWarnings("unchecked") public static void main(String[] args) throws IOException { String host = "localhost"; String port = null;/*from w w w . java2s . c o m*/ int indx = 0; String serviceName = null; System.out.println("Node bootstrap params: " + Arrays.asList(args)); while (indx < args.length && args[indx].startsWith("-")) { if (args[indx].equalsIgnoreCase("-p")) { port = args[++indx]; log("Port=" + port); } else if (args[indx].equalsIgnoreCase("-h")) { host = args[++indx]; log("Host=" + host); } else if (args[indx].equalsIgnoreCase("-b")) { serviceName = args[++indx]; log("Broker ServiceName=" + serviceName); } indx++; } if (port == null) { throw new RuntimeException("Port not set"); } if (serviceName == null) { throw new RuntimeException("Broker Service Name not set"); } RmiProxyFactoryBean s = new RmiProxyFactoryBean(); s.setServiceUrl("rmi://" + host + ":" + port + "/" + serviceName); s.setServiceInterface(IBroker.class); s.afterPropertiesSet(); IBroker<Object> broker = (IBroker<Object>) s.getObject(); RemoteExecutorNode<Object> remoteExecutor = new RemoteExecutorNode<Object>(broker); GridConfig gridConfig = broker.getBrokerInfo().getConfig(); if (gridConfig.libraryPathDefined()) { String libraryPath = gridConfig.getLibraryPath(); ClassLoader loader = getClassLoader(libraryPath); Thread.currentThread().setContextClassLoader(loader); } InjectionInterceptor interceptor = new InjectionInterceptor(); if (gridConfig.injectionContextDefined()) { String injectionContext = gridConfig.getInjectionContext(); ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(injectionContext); interceptor.setContext(ctx); } interceptor.addBean("monitor", broker.getProgressMonitor()); remoteExecutor.add(interceptor); remoteExecutor.start(); }
From source file:com.lostinsoftware.xsdparser.XSDParserTest.java
public static void main(String[] argv) { try {/*from w ww. java2 s .c o m*/ URL url = XSDParserTest.class.getClassLoader() .getResource("com/lostinsoftware/xsdparser/xsd/database_test.xsd"); List<String> data = Arrays.asList(elements); XSDElement mainElement = XSDParser.parseXSD(url, data); // Print all data System.out.println("=============== Only some elements ======================="); printData(mainElement, 0); mainElement = XSDParser.parseXSD(url, "database"); // Print all data System.out.println("\n\n=============== All elements ======================="); printData(mainElement, 0); } catch (Exception ex) { ex.printStackTrace(); } }
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(Arrays.asList(emps)); System.out.println(set);/*from ww w .ja v a 2 s. com*/ }
From source file:com.termmed.sampling.ConceptsWithMoreThanThreeRoleGroups.java
/** * The main method.//from w w w . jav a2 s . c o m * * @param args the arguments * @throws Exception the exception */ public static void main(String[] args) throws Exception { System.out.println("Starting..."); Map<String, Set<String>> groupsMap = new HashMap<String, Set<String>>(); File relsFile = new File( "/Users/alo/Downloads/SnomedCT_RF2Release_INT_20160131-1/Snapshot/Terminology/sct2_Relationship_Snapshot_INT_20160131.txt"); BufferedReader br2 = new BufferedReader(new FileReader(relsFile)); String line2; int count2 = 0; while ((line2 = br2.readLine()) != null) { // process the line. count2++; if (count2 % 10000 == 0) { //System.out.println(count2); } List<String> columns = Arrays.asList(line2.split("\t", -1)); if (columns.size() >= 6) { if (columns.get(2).equals("1") && !columns.get(6).equals("0")) { if (!groupsMap.containsKey(columns.get(4))) { groupsMap.put(columns.get(4), new HashSet<String>()); } groupsMap.get(columns.get(4)).add(columns.get(6)); } } } System.out.println("Relationship groups loaded"); Gson gson = new Gson(); System.out.println("Reading JSON 1"); File crossoverFile1 = new File("/Users/alo/Downloads/crossover_role_to_group.json"); String contents = FileUtils.readFileToString(crossoverFile1, "utf-8"); Type collectionType = new TypeToken<Collection<ControlResultLine>>() { }.getType(); List<ControlResultLine> lineObject = gson.fromJson(contents, collectionType); Set<String> crossovers1 = new HashSet<String>(); for (ControlResultLine loopResult : lineObject) { crossovers1.add(loopResult.conceptId); } System.out.println("Crossovers 1 loaded, " + lineObject.size() + " Objects"); System.out.println("Reading JSON 2"); File crossoverFile2 = new File("/Users/alo/Downloads/crossover_group_to_group.json"); String contents2 = FileUtils.readFileToString(crossoverFile2, "utf-8"); List<ControlResultLine> lineObject2 = gson.fromJson(contents2, collectionType); Set<String> crossovers2 = new HashSet<String>(); for (ControlResultLine loopResult : lineObject2) { crossovers2.add(loopResult.conceptId); } System.out.println("Crossovers 2 loaded, " + lineObject2.size() + " Objects"); Set<String> foundConcepts = new HashSet<String>(); int count3 = 0; BufferedWriter writer = new BufferedWriter( new FileWriter(new File("ConceptsWithMoreThanThreeRoleGroups.csv"))); ; for (String loopConcept : groupsMap.keySet()) { if (groupsMap.get(loopConcept).size() > 3) { writer.write(loopConcept); writer.newLine(); foundConcepts.add(loopConcept); count3++; } } writer.close(); System.out.println("Found " + foundConcepts.size() + " concepts"); int countCrossover1 = 0; for (String loopConcept : foundConcepts) { if (crossovers1.contains(loopConcept)) { countCrossover1++; } } System.out.println(countCrossover1 + " are present in crossover_role_to_group"); int countCrossover2 = 0; for (String loopConcept : foundConcepts) { if (crossovers2.contains(loopConcept)) { countCrossover2++; } } System.out.println(countCrossover2 + " are present in crossover_group_to_group"); System.out.println("Done"); }