List of usage examples for java.util ArrayList toArray
@SuppressWarnings("unchecked") public <T> T[] toArray(T[] a)
From source file:com.prowidesoftware.swift.utils.TestUtils.java
/** * Returns an array of empty value tags enclosed in 16RS with the given qualifier * @param startEnd16rs qualifier for 16RS tag * @param tagnames tag names to create/*from www . j a v a2 s . c o m*/ * @return the created array of tag objects */ public static Tag[] newSeq(final String startEnd16rs, final String... tagnames) { final ArrayList<Tag> result = new ArrayList<Tag>(); result.add(new Tag("16R", startEnd16rs)); if (tagnames != null && tagnames.length > 0) { for (final String name : tagnames) { result.add(new Tag(name, "")); } } result.add(new Tag("16S", startEnd16rs)); return (Tag[]) result.toArray(new Tag[result.size()]); }
From source file:li.klass.fhem.testsuite.category.CategorySuite.java
private static Class<?>[] getSuiteClasses() { String basePath = getBasePath(); File basePathFile = new File(basePath); Collection javaFiles = FileUtils.listFiles(basePathFile, new String[] { "java" }, true); ArrayList<Class<?>> result = new ArrayList<Class<?>>(); for (Object fileObject : javaFiles) { File file = (File) fileObject; Class<?> cls = toClass(file, basePath); if (cls == null || Modifier.isAbstract(cls.getModifiers())) { continue; }/*from www .ja v a 2s .c o m*/ result.add(cls); } return result.toArray(new Class<?>[result.size()]); }
From source file:Main.java
public static Element[] getChildElementNodesByName(Node node, String name) { if (node == null) { return null; }/*from w ww . j a v a 2 s .c o m*/ ArrayList<Element> elements = new ArrayList<>(); NodeList nodeList = node.getChildNodes(); if (nodeList != null && nodeList.getLength() > 0) { for (int i = 0; i < nodeList.getLength(); i++) { Node item = nodeList.item(i); if (item != null && (node.getNodeType() == Node.ELEMENT_NODE) && name.equalsIgnoreCase(item.getNodeName())) { elements.add((Element) item); } } } return elements.toArray(new Element[elements.size()]); }
From source file:eu.e43.impeller.Utils.java
public static Uri getUserUri(Context ctx, Account user, String... components) { AccountManager am = AccountManager.get(ctx); String username = am.getUserData(user, "username"); ArrayList<String> parts = new ArrayList<String>(); parts.add("api"); parts.add("user"); parts.add(username);/* ww w . j a v a 2 s . c o m*/ for (String s : components) parts.add(s); return getHostUri(ctx, user, parts.toArray(components)); }
From source file:org.n52.movingcode.runtime.processors.config.ProcessorConfig.java
/** * Getter for registered processor IDs//w w w.ja va 2s . c om * * @return */ public static final String[] getRegisteredProcessorIDs() { ArrayList<String> processorList = new ArrayList<String>(); // remove default id since this is not considered a processor for (String proc : processors.keySet()) { if (proc != DEFAULT_PROCESSOR_CONFIG_ID) { processorList.add(proc); } } return processorList.toArray(new String[processorList.size()]); }
From source file:com.appspresso.api.fs.FileSystemUtils.java
/** * path path separator ./* w ww.j av a 2 s.co m*/ * * @param path path * @return ? path component? */ public static String[] split(String path) { String[] pathArray = path.split(File.separator); ArrayList<String> newPathArray = new ArrayList<String>(); int length = pathArray.length; for (int i = 0; i < length; i++) { if (TextUtils.isEmpty(pathArray[i])) continue; newPathArray.add(pathArray[i]); } return newPathArray.toArray(new String[newPathArray.size()]); }
From source file:com.sic.bb.jenkins.plugins.sicci_for_xcode.io.XcodebuildOutputParser.java
public static String[] getAvailableSdks(FilePath workspace) { ArrayList<String> sdks = new ArrayList<String>(); String sdksString = XcodebuildCommandCaller.getInstance().getOutput(workspace, "-list"); if (StringUtils.isBlank(sdksString)) return new String[0]; for (String sdk : sdksString.split("\n")) { if (!sdk.contains("-sdk")) continue; sdks.add(availableSdksPattern.matcher(sdk).replaceAll("$1")); }// www . j a va 2 s.com return (String[]) sdks.toArray(new String[sdks.size()]); }
From source file:Main.java
public static String[] splitByWhitespace(String str) { ArrayList<String> list = new ArrayList<String>(); StringBuilder buf = new StringBuilder(); for (int i = 0; i < str.length(); i++) { char ch = str.charAt(i); if (ch == ' ' || ch == '\t') { if (buf.length() > 0) { list.add(buf.toString()); buf = new StringBuilder(); }//from w ww . jav a2 s .co m } else { buf.append(ch); } } if (buf.length() > 0) list.add(buf.toString()); return list.toArray(new String[list.size()]); }
From source file:org.prx.playerhater.util.PlaylistParser.java
private static Uri[] parseM3u(Uri uri) { try {//from w ww. ja va 2 s. com HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = httpclient.execute(new HttpGet(uri.toString())); HttpEntity entity = response.getEntity(); InputStream inputStream = entity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line; ArrayList<Uri> uriList = new ArrayList<Uri>(); do { line = reader.readLine(); if (line != null) { if (!line.startsWith("#")) { uriList.add(Uri.parse(line.trim())); } } } while (line != null); if (uriList.size() > 0) { Uri[] res = new Uri[uriList.size()]; return uriList.toArray(res); } } catch (Exception e) { } return new Uri[] { uri }; }
From source file:com.dicksoft.ocr.util.StringUtil.java
/** * Get all instances of the String between matches of a and subsequent * matches of b from source./*from w ww .j ava2s .c om*/ * * @param source * the source String * @param a * the first boundary * @param b * the second boundary * @return the Strings between, or an empty array if either boundary was not * found in the source or if the String between was the empty * String, "". */ public static String[] getBetweens(String source, String a, String b) { ArrayList<String> result = new ArrayList<String>(); int aIndex = 0; int bIndex = 0; for (int i = 0;; i = bIndex + b.length()) { aIndex = source.indexOf(a, i); if (aIndex == -1) { LOG.debug("String a, " + a + " was not found in the target String, starting at " + i); return result.toArray(new String[result.size()]); } bIndex = source.indexOf(b, aIndex + a.length()); if (bIndex == -1) { LOG.debug("String b, " + b + " was not found in the target String."); return result.toArray(new String[result.size()]); } String next = source.substring(aIndex + a.length(), bIndex); if (next.equals("")) return result.toArray(new String[result.size()]); result.add(next); } }