List of usage examples for java.util ArrayList toArray
@SuppressWarnings("unchecked") public <T> T[] toArray(T[] a)
From source file:Main.java
@SuppressWarnings("nls") public static String[] getStringIdArray(String serializedTree) { ArrayList<String> ids = new ArrayList<String>(); String[] values = serializedTree.split("[\\[\\],\"\\s]"); // Split on [ ] , or whitespace chars for (String idString : values) { if (!TextUtils.isEmpty(idString)) ids.add(idString);/* w ww.j a v a 2 s .c om*/ } return ids.toArray(new String[ids.size()]); }
From source file:Main.java
/** * Gets all threads if its name matches a regular expression. For example, * using a regex of "main" will execute a case-sensitive match for threads * with the exact name of "main". A regex of ".*main.*" will execute a * case sensitive match for threads with "main" anywhere in their name. A * regex of "(?i).*main.*" will execute a case insensitive match of any * thread that has "main" in its name.//from w w w .j a v a2 s. c o m * @param regex The regular expression to use when matching a threads name. * Same rules apply as String.matches() method. * @return An array (will not be null) of all matching threads. An empty * array will be returned if no threads match. */ static public Thread[] getAllThreadsMatching(final String regex) { if (regex == null) throw new NullPointerException("Null thread name regex"); final Thread[] threads = getAllThreads(); ArrayList<Thread> matchingThreads = new ArrayList<Thread>(); for (Thread thread : threads) { if (thread.getName().matches(regex)) { matchingThreads.add(thread); } } return matchingThreads.toArray(new Thread[0]); }
From source file:Main.java
public static String[] getStringIdArray(String serializedTree) { ArrayList<String> ids = new ArrayList<>(); String[] values = serializedTree.split("[\\[\\],\"\\s]"); // Split on [ ] , or whitespace chars for (String idString : values) { if (!TextUtils.isEmpty(idString)) { ids.add(idString);/*from w w w . j a va 2 s. c o m*/ } } return ids.toArray(new String[ids.size()]); }
From source file:TokenizerUtil.java
public static String[] convertCSVStringToArray(String s) { ArrayList<String> list = new ArrayList<String>(); StringTokenizer st = new StringTokenizer(s, "|"); while (st.hasMoreTokens()) { String token = st.nextToken(); list.add(token);/*from w w w. ja va2 s . c o m*/ } return (String[]) list.toArray(new String[list.size()]); }
From source file:Main.java
public static Node[] findNodesByTagName(Document document, String tagName) { ArrayList<Node> nodes = new ArrayList<Node>(); NodeList foundNodes = document.getElementsByTagName(tagName); for (int i = 0; i < foundNodes.getLength(); i++) nodes.add(foundNodes.item(i));// w w w.java 2 s . c o m Node[] returnNodes = new Node[nodes.size()]; return nodes.toArray(returnNodes); }
From source file:Main.java
/** * Reads a sentence from the a reader and returns a string array with tokens. * /*from ww w. j a v a 2 s . c o m*/ * The method expect that each line contains a token and empty line is equal to end of sentence. * * There are no check for particular data format so if the input is garbage then the output will also be garbage. * * @param reader a buffered reader * @return a string array with tokens * @throws IOException */ public static String[] readSentence(BufferedReader reader) throws IOException { ArrayList<String> tokens = new ArrayList<String>(); String line; while ((line = reader.readLine()) != null) { if (line.trim().length() == 0) { break; } else { tokens.add(line.trim()); } } return tokens.toArray(new String[tokens.size()]); }
From source file:com.acme.spring.jms.Deployments.java
/** * <p>Retrieves the dependencies.</p> * * @return the array of the dependencies *//*from www .j a v a 2 s .c o 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-jms:3.1.1.RELEASE")); return files.toArray(new File[files.size()]); }
From source file:filterviewplugin.FilterViewSettings.java
static String[] getAvailableFilterNames() { ArrayList<String> names = new ArrayList<String>(); for (ProgramFilter filter : getAvailableFilters()) { names.add(filter.getName());//from w w w .ja va 2 s . c om } return names.toArray(new String[names.size()]); }
From source file:Main.java
public static void unRevokePermission(String packageName, String permission, Context ctx) { String[] rPerms = getRevokedPerms(packageName, ctx); if (rPerms == null) rPerms = new String[0]; ArrayList<String> revokedPerms = new ArrayList<String>(); revokedPerms.addAll(Arrays.asList(rPerms)); if (revokedPerms.contains(permission)) { revokedPerms.remove(permission); String[] permsToRevoke = new String[revokedPerms.size()]; revokedPerms.toArray(permsToRevoke); setRevokedPermissions(packageName, permsToRevoke, ctx); }/* w ww .j av a 2 s. c o m*/ }
From source file:Main.java
public static void revokePermission(String packageName, String permission, Context ctx) { String[] rPerms = getRevokedPerms(packageName, ctx); if (rPerms == null) rPerms = new String[0]; ArrayList<String> revokedPerms = new ArrayList<String>(); revokedPerms.addAll(Arrays.asList(rPerms)); if (!revokedPerms.contains(permission)) { revokedPerms.add(permission);/*from w w w .j a va 2 s . c om*/ String[] permsToRevoke = new String[revokedPerms.size()]; revokedPerms.toArray(permsToRevoke); setRevokedPermissions(packageName, permsToRevoke, ctx); } }