List of usage examples for java.util List get
E get(int index);
From source file:Main.java
public static void main(String[] args) { List<String> stringList = Arrays.asList(args); System.out.println("before: " + stringList); for (int i = 0; i < stringList.size(); ++i) { stringList.set(i, stringList.get(i).replaceAll("\\s+", "")); }// ww w . j av a 2 s . c om System.out.println("after : " + stringList); }
From source file:MimeTypesDemo.java
public static void main(String[] args) { ScriptEngineManager manager = new ScriptEngineManager(); List<ScriptEngineFactory> factories = manager.getEngineFactories(); for (ScriptEngineFactory factory : factories) { List<String> mimeTypes = factory.getMimeTypes(); for (int i = 0; i < mimeTypes.size(); i++) { System.out.printf("Supported MIME type " + i + " " + (String) mimeTypes.get(i) + "\n"); }/*from ww w . j a v a2 s. c o m*/ } }
From source file:sample.fa.ScriptRunnerApplicationMac.java
public static void main(String[] args) { SwingUtilities.invokeLater(() -> { ScriptRunnerApplication app = new ScriptRunnerApplication(); app.createGUI();//from w ww . j a va 2 s. co m if (args.length > 0) { File f = new File(args[0]); if (f.isFile()) { app.loadScript(f); } } Application.getApplication().setOpenFileHandler((AppEvent.OpenFilesEvent ofe) -> { List<File> files = ofe.getFiles(); if (files != null && files.size() > 0) { app.loadScript(files.get(0)); } }); }); }
From source file:Main.java
public static void main(String[] argv) { List<URL> urlList = new ArrayList<URL>(); try {// w w w . j a v a 2 s . co m urlList.add(new URL("http://www.java2s.com")); } catch (MalformedURLException e) { } String s = urlList.get(0).getHost(); }
From source file:MainClass.java
License:asdf
public static void main(String[] args) throws Exception { String characterName = "asdf"; SAXBuilder builder = new SAXBuilder(); Document document = builder.build(new File("r.xml")); List actList = document.getRootElement().getChildren("ACT"); allDone: for (int act = 0; act < actList.size(); act++) { List sceneList = ((Element) actList.get(act)).getChildren("SCENE"); for (int scene = 0; scene < sceneList.size(); scene++) { List speechList = ((Element) sceneList.get(scene)).getChildren("SPEECH"); for (int speech = 0; speech < speechList.size(); speech++) { if (characterName .equalsIgnoreCase(((Element) speechList.get(speech)).getChildText("SPEAKER"))) { System.out.println(characterName); break allDone; }//from w w w .j a v a 2 s . c o m } } } }
From source file:Main.java
public static void main(String[] args) { String[] peoples = { "A", "B", "C", "D", "E", "F" }; List<String> names = Arrays.asList(peoples); for (int i = 0; i < peoples.length; i++) { int index = new Random().nextInt(names.size()); String anynames = names.get(index); System.out.println(anynames); }/*w w w . j a v a 2 s. c o m*/ }
From source file:jlibs.examples.jdbc.DB.java
public static void main(String[] args) throws Exception { try {/*from w ww .j ava 2 s . c om*/ assert false; throw new RuntimeException("assertions are not enabled"); } catch (AssertionError ignore) { // ignore } EMPLOYEES.delete(); assert EMPLOYEES.all().size() == 0; Employee emp = new Employee(); emp.id = 1; emp.setFirstName("santhosh"); emp.setLastName("kumar"); emp.setAge(25); EMPLOYEES.insert(emp); assert EMPLOYEES.all().size() == 1; emp.setAge(20); EMPLOYEES.update(emp); assert EMPLOYEES.all().get(0).getAge() == 20; try { JDBC.run(new Transaction<Object>() { @Override public Object run(Connection con) throws SQLException { Employee emp = new Employee(); emp.id = 2; emp.setFirstName("santhosh"); emp.setLastName("kumar"); emp.setAge(25); EMPLOYEES.insert(emp); emp.id = 3; EMPLOYEES.insert(emp); assert EMPLOYEES.all().size() == 3; // assert table.findOlderEmployees(1).size()==2; throw new RuntimeException(); } }); } catch (RuntimeException ignore) { // ignore } // assert table.findOlderEmployees(1).size()==0; System.out.println(EMPLOYEES.all().size()); assert EMPLOYEES.all().size() == 1; emp.setAge(10); EMPLOYEES.upsert(emp); assert EMPLOYEES.first("where id=?", emp.id).getAge() == 10; emp.id = -1; emp.setLastName("KUMAR"); EMPLOYEES.upsert(emp); assert EMPLOYEES.first("where last_name=?", "KUMAR") != null; assert EMPLOYEES.all().size() == 2; List<Employee> list = EMPLOYEES.all(); list.get(0).setAge(29); EMPLOYEES.update(list.get(0)); EMPLOYEES.delete(list.get(0)); // List<Employee> list = table.findYoungEmployees(50); // Employee emp1 = EMPLOYEES.get(1); }
From source file:org.seasar.dao.spring.example.EmployeeDaoClient.java
public static void main(final String[] args) { final BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance(); final BeanFactoryReference ref = locator.useBeanFactory("context"); final ApplicationContext context = (ApplicationContext) ref.getFactory(); try {/* w ww .j ava 2 s . c o m*/ final EmployeeDao dao = (EmployeeDao) context.getBean("employeeDao"); final List employees = dao.getAllEmployees(); for (int i = 0; i < employees.size(); ++i) { System.out.println(employees.get(i)); } final Employee employee = dao.getEmployee(7788); System.out.println(employee); final int count = dao.getCount(); System.out.println("count:" + count); dao.getEmployeeByJobDeptno(null, null); dao.getEmployeeByJobDeptno("CLERK", null); dao.getEmployeeByJobDeptno(null, new Integer(20)); dao.getEmployeeByJobDeptno("CLERK", new Integer(20)); dao.getEmployeeByDeptno(new Integer(20)); dao.getEmployeeByDeptno(null); System.out.println("updatedRows:" + dao.update(employee)); } finally { ref.release(); } }
From source file:Main.java
public static void main(String[] args) throws Exception { File xml = new File("yourFile.xml"); Document doc = (Document) new SAXBuilder().build(xml); Element rootNode = doc.getRootElement(); List list = rootNode.getChildren("staff"); XMLOutputter xmlOut = new XMLOutputter(); for (int i = 0; i < list.size(); i++) { Element node = (Element) list.get(i); if (node.getChildText("firstname").equals("sanjay")) node.getChild("salary").getChild("basic").setText("250000"); xmlOut.setFormat(Format.getPrettyFormat()); xmlOut.output(doc, new FileWriter("yourFile.xml")); }/*from w w w.jav a 2s . c o m*/ }
From source file:ac.simons.tweetarchive.Application.java
public static void main(final String... args) throws Exception { final OptionParser optionParser = new OptionParser(); optionParser.allowsUnrecognizedOptions(); optionParser.acceptsAll(Arrays.asList("g", "generate-tokens")).withRequiredArg().withValuesSeparatedBy(","); final OptionSet optionSet = optionParser.parse(args); if (optionSet.hasArgument("g")) { final List<String> values = (List<String>) optionSet.valuesOf("g"); createTwitterOauthTokens(values.get(0), values.get(1)); } else {//from www. ja v a 2 s . c o m SpringApplication.run(Application.class, args); } }