List of usage examples for java.util Arrays asList
@SafeVarargs @SuppressWarnings("varargs") public static <T> List<T> asList(T... a)
From source file:MainClass.java
public static void main(String args[]) { JFrame frame = new JFrame("Reverse Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(3, 3)); for (int i = 9; i > 0; i--) { JButton button = new JButton(Integer.toString(i)); frame.add(button, 0);// ww w .j av a 2s .c o m } final Container contentPane = frame.getContentPane(); Comparator<Component> comp = new Comparator<Component>() { public int compare(Component c1, Component c2) { Component comps[] = contentPane.getComponents(); List list = Arrays.asList(comps); int first = list.indexOf(c1); int second = list.indexOf(c2); return second - first; } }; FocusTraversalPolicy policy = new SortingFocusTraversalPolicy(comp); frame.setFocusTraversalPolicy(policy); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); XMLEventWriter writer = outputFactory.createXMLEventWriter(System.out); XMLEventFactory xmlEventFactory = XMLEventFactory.newInstance(); StartDocument startDocument = xmlEventFactory.createStartDocument("UTF-8", "1.0"); writer.add(startDocument);//from w w w . j a v a 2s. com StartElement startElement = xmlEventFactory.createStartElement("", "", "My-list"); writer.add(startElement); Attribute attribute = xmlEventFactory.createAttribute("version", "1"); List attributeList = Arrays.asList(attribute); List nsList = Arrays.asList(); StartElement startElement2 = xmlEventFactory.createStartElement("", "", "Item", attributeList.iterator(), nsList.iterator()); writer.add(startElement2); StartElement codeSE = xmlEventFactory.createStartElement("", "", "code"); writer.add(codeSE); Characters codeChars = xmlEventFactory.createCharacters("I001"); writer.add(codeChars); EndElement codeEE = xmlEventFactory.createEndElement("", "", "code"); writer.add(codeEE); StartElement nameSE = xmlEventFactory.createStartElement(" ", " ", "name"); writer.add(nameSE); Characters nameChars = xmlEventFactory.createCharacters("a name"); writer.add(nameChars); EndElement nameEE = xmlEventFactory.createEndElement("", "", "name"); writer.add(nameEE); StartElement contactSE = xmlEventFactory.createStartElement("", "", "contact"); writer.add(contactSE); Characters contactChars = xmlEventFactory.createCharacters("another name"); writer.add(contactChars); EndElement contactEE = xmlEventFactory.createEndElement("", "", "contact"); writer.add(contactEE); EndDocument ed = xmlEventFactory.createEndDocument(); writer.add(ed); writer.flush(); writer.close(); }
From source file:de.tudarmstadt.ukp.dkpro.core.toolbox.tutorial.FrequencyDistributionTutorial.java
public static void main(String[] args) { List<String> tokens = Arrays .asList(StringUtils.split("This is a simple example sentence containing an example .")); FrequencyDistribution<String> fq = new FrequencyDistribution<String>(tokens); System.out.println(fq.getCount("example")); System.out.println(fq.getCount("is")); }
From source file:XMLEventWriterDemo.java
public static void main(String[] args) throws Exception { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); XMLEventWriter writer = outputFactory.createXMLEventWriter(System.out); XMLEventFactory xmlEventFactory = XMLEventFactory.newInstance(); StartDocument startDocument = xmlEventFactory.createStartDocument("UTF-8", "1.0"); writer.add(startDocument);/* w w w.j a v a2 s . co m*/ StartElement startElement = xmlEventFactory.createStartElement("", "", "My-list"); writer.add(startElement); Attribute attribute = xmlEventFactory.createAttribute("version", "1"); List attributeList = Arrays.asList(attribute); List nsList = Arrays.asList(); StartElement startElement2 = xmlEventFactory.createStartElement("", "", "Item", attributeList.iterator(), nsList.iterator()); writer.add(startElement2); StartElement codeSE = xmlEventFactory.createStartElement("", "", "code"); writer.add(codeSE); Characters codeChars = xmlEventFactory.createCharacters("I001"); writer.add(codeChars); EndElement codeEE = xmlEventFactory.createEndElement("", "", "code"); writer.add(codeEE); StartElement nameSE = xmlEventFactory.createStartElement(" ", " ", "name"); writer.add(nameSE); Characters nameChars = xmlEventFactory.createCharacters("a name"); writer.add(nameChars); EndElement nameEE = xmlEventFactory.createEndElement("", "", "name"); writer.add(nameEE); StartElement contactSE = xmlEventFactory.createStartElement("", "", "contact"); writer.add(contactSE); Characters contactChars = xmlEventFactory.createCharacters("another name"); writer.add(contactChars); EndElement contactEE = xmlEventFactory.createEndElement("", "", "contact"); writer.add(contactEE); EndDocument ed = xmlEventFactory.createEndDocument(); writer.add(ed); writer.flush(); writer.close(); }
From source file:com.home.ln_spring.ch4.xml.BeanNameAliasing.java
public static void main(String args[]) { GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.load("classpath:app-context-xml.xml"); context.refresh();/* w w w . j ava 2 s . c o m*/ String str1 = (String) context.getBean("name1"); String str2 = (String) context.getBean("name2"); String str3 = (String) context.getBean("name3"); String str4 = (String) context.getBean("name4"); String str5 = (String) context.getBean("name5"); String[] alias = (String[]) context.getAliases("name1"); System.out.println(str1 == str2); System.out.println(str2 == str3); System.out.println(str3 == str4); System.out.println(str4 == str5); System.out.println(str1 == str5); System.out.println(Arrays.asList(alias)); }
From source file:com.fizzed.stork.test.HelloMain.java
static public void main(String[] args) throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); HelloOutput output = new HelloOutput(); output.setConfirm("Hello World!"); output.setEnvironment(System.getenv()); output.setSystemProperties(System.getProperties()); output.setArguments(Arrays.asList(args)); mapper.writeValue(System.out, output); }
From source file:com.fluke.application.IEODReader.java
public static void main(String[] args) throws IOException { String location = "/home/arshed/Pictures/sample"; list = IOUtils.readLines(ClassLoader.getSystemResourceAsStream("config/stocks")); File folder = new File(location); processFolder(Arrays.asList(folder)); }
From source file:Person.java
public static void main(String args[]) { Person emps[] = { new Person("Debbie", "Degree"), new Person("Geri", "Grade"), new Person("Ester", "Extent"), new Person("Mary", "Measure"), new Person("Anastasia", "Amount") }; Set set = new TreeSet(Arrays.asList(emps)); System.out.println(set);/* w w w . j a va 2 s . c o m*/ }
From source file:mase.MaseEvolve.java
public static void main(String[] args) throws Exception { File outDir = getOutDir(args); boolean force = Arrays.asList(args).contains(FORCE); if (!outDir.exists()) { outDir.mkdirs();//from w w w . ja v a 2s .c o m } else if (!force) { System.out.println("Folder already exists: " + outDir.getAbsolutePath() + ". Waiting 5 sec."); try { Thread.sleep(5000); } catch (InterruptedException ex) { } } // Get config file Map<String, String> pars = readParams(args); // Copy config to outdir try { File rawConfig = writeConfig(args, pars, outDir, false); File destiny = new File(outDir, DEFAULT_CONFIG); destiny.delete(); FileUtils.moveFile(rawConfig, new File(outDir, DEFAULT_CONFIG)); } catch (Exception ex) { ex.printStackTrace(); } // JBOT INTEGRATION: copy jbot config file to the outdir // Does nothing when jbot is not used if (pars.containsKey("problem.jbot-config")) { File jbot = new File(pars.get("problem.jbot-config")); FileUtils.copyFile(jbot, new File(outDir, jbot.getName())); } // Write config to system temp file File config = writeConfig(args, pars, outDir, true); // Launch launchExperiment(config); }
From source file:Name.java
public static void main(String[] args) { Name name = new Name("A", "C"); Name name1 = new Name("A", "B"); Name name2 = new Name("C", "F"); Name name3 = new Name("D", "A"); Name name4 = new Name("Ca", "D"); Name name5 = new Name("Cc", "Z"); Name name6 = new Name("Cc", "W"); Name nameArray[] = { name, name1, name2, name3, name4, name5, name6 }; List<Name> names = new ArrayList<Name>(Arrays.asList(nameArray)); Collections.sort(names);/*from w w w .jav a2 s . c o m*/ for (Name n : names) { System.out.println(n.getFirstName() + " " + n.getLastName()); } }