List of usage examples for java.util ArrayList toArray
@SuppressWarnings("unchecked") public <T> T[] toArray(T[] a)
From source file:Main.java
public static String[] split(String paramString1, String paramString2) { int i = paramString1.indexOf(paramString2); if (i == -1)// ww w .j ava2s. co m return new String[] { paramString1 }; ArrayList localArrayList = new ArrayList(); int j = 0; while (i != -1) { localArrayList.add(paramString1.substring(j, i)); j = i + paramString2.length(); i = paramString1.indexOf(paramString2, j); } if (j != paramString1.length()) localArrayList.add(paramString1.substring(j)); return (String[]) localArrayList.toArray(new String[localArrayList.size()]); }
From source file:io.fluo.stress.TrieMapRedIT.java
static int unique(File... dirs) throws Exception { ArrayList<String> args = new ArrayList<>( Arrays.asList("-D", "mapred.job.tracker=local", "-D", "fs.defaultFS=file:///")); for (File dir : dirs) { args.add(dir.toURI().toString()); }//from ww w .j a va 2 s . c om int ret = ToolRunner.run(new Unique(), args.toArray(new String[args.size()])); Assert.assertEquals(0, ret); return Unique.getNumUnique(); }
From source file:Main.java
/** * Access all immediate child elements inside the given Element * * @param element the starting element, cannot be null. * @param elemName the name of the child element to look for, cannot be * null./*www . j a va2 s .c o m*/ * @return array of all immediate child element inside element, or * an array of size zero if no child elements are found. */ public static Element[] getChildElements(Element element) { NodeList list = element.getChildNodes(); int len = list.getLength(); ArrayList<Node> array = new ArrayList<Node>(len); for (int i = 0; i < len; i++) { Node n = list.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { array.add(n); } } Element[] elems = new Element[array.size()]; return (Element[]) array.toArray(elems); }
From source file:Main.java
/** * Returns a set with all attribute values for the specified attributes within the element. * @param expectedChild/*from w w w. j a v a 2 s. co m*/ * @param identifyingAttributes * @return */ private static String[] getAttributeValues(Element element, String[] identifyingAttributes) { ArrayList<String> values = new ArrayList<String>(); for (int i = 0; i < identifyingAttributes.length; i++) { values.add(element.getAttribute(identifyingAttributes[i])); } return values.toArray(new String[values.size()]); }
From source file:com.qmetry.qaf.automation.integration.qmetry.qmetry7.QMetry7ResultUpdator.java
public static Integer[] extractNums(String s) { ArrayList<Integer> lst = new ArrayList<Integer>(); Pattern p = Pattern.compile("(\\d)+"); Matcher m = p.matcher(s);/*from ww w .ja va2 s.c o m*/ while (m.find()) { lst.add(Integer.parseInt(m.group())); } return lst.toArray(new Integer[lst.size()]); }
From source file:cz.zeno.miner.Utils.java
public static String[] getAvailableSerialPorts() { java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers(); ArrayList<String> serialPorts = new ArrayList<>(); while (portEnum.hasMoreElements()) { CommPortIdentifier portIdentifier = portEnum.nextElement(); if (CommPortIdentifier.PORT_SERIAL == portIdentifier.getPortType()) { serialPorts.add(portIdentifier.getName()); }/*from w w w. jav a 2s. co m*/ } return serialPorts.toArray(new String[0]); }
From source file:io.github.jeremgamer.editor.panels.Actions.java
public static String[] getActions() { ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < actionList.getModel().getSize(); i++) { list.add(actionList.getModel().getElementAt(i)); }/*www . j a v a 2 s .c o m*/ return list.toArray(new String[0]); }
From source file:com.addthis.hydra.data.query.Query.java
/** * turns compact query notation (+:+hits) into an object array *///from w w w .j av a 2s . c o m private static QueryElement[] parseQueryPath(String path) { MutableInt column = new MutableInt(0); ArrayList<QueryElement> list = new ArrayList<>(); for (String pe : LessStrings.split(path, "/")) { list.add(new QueryElement().parse(pe, column)); } return list.toArray(new QueryElement[list.size()]); }
From source file:com.acme.spring.jdbc.Deployments.java
/** * <p>Retrieves the dependencies.</p> * * @return the array of the dependencies */// ww w. j a v a 2 s. co m public static File[] springDependencies() { ArrayList<File> files = new ArrayList<File>(); files.addAll(resolveDependencies("org.springframework:spring-context:3.1.1.RELEASE")); files.addAll(resolveDependencies("org.springframework:spring-jdbc:3.1.1.RELEASE")); files.addAll(resolveDependencies("org.springframework:spring-tx:3.1.1.RELEASE")); return files.toArray(new File[files.size()]); }
From source file:com.acme.spring.jpa.Deployments.java
/** * <p>Retrieves the dependencies.</p> * * @return the array of the dependencies *///w w w. j a v a2s .c om public static File[] springDependencies() { ArrayList<File> files = new ArrayList<File>(); files.addAll(resolveDependencies("org.springframework:spring-context:3.1.1.RELEASE")); files.addAll(resolveDependencies("org.springframework:spring-orm:3.1.1.RELEASE")); files.addAll(resolveDependencies("org.springframework:spring-tx:3.1.1.RELEASE")); return files.toArray(new File[files.size()]); }