List of usage examples for java.util ArrayList toArray
@SuppressWarnings("unchecked") public <T> T[] toArray(T[] a)
From source file:com.thoughtworks.twist.mingle.core.MingleUtils.java
public static String getQueryUrlAfterEncodingURL(String fullUrl) throws UnsupportedEncodingException { String queryUrl = fullUrl.substring(fullUrl.indexOf('?') + 1); String[] split = queryUrl.split("&"); ArrayList<NameValuePair> pairs = new ArrayList<NameValuePair>(); for (String nameValuePair : split) { if (nameValuePair.contains("=")) { int indexOfEquals = nameValuePair.indexOf('='); String name = nameValuePair.substring(0, indexOfEquals); String value = nameValuePair.substring(indexOfEquals + 1); name = URLDecoder.decode(name, "utf-8"); value = URLDecoder.decode(value, "utf-8"); pairs.add(new NameValuePair(name, value)); }/*w w w . jav a2 s.c om*/ } String formUrlEncode = EncodingUtil.formUrlEncode(pairs.toArray(new NameValuePair[0]), "utf-8"); return formUrlEncode; }
From source file:com.opendoorlogistics.core.utils.ui.FileBrowserPanel.java
public static JComponent[] createComponents(String label, String initialFilename, final FilenameChangeListener filenameChangeListener, final boolean directoriesOnly, final String browserApproveButtonText, final FileFilter... fileFilters) { ArrayList<JComponent> ret = new ArrayList<JComponent>(); if (label != null) { ret.add(new JLabel(label)); }/*from ww w. java 2 s . c o m*/ JTextField textField = createTextField(initialFilename, filenameChangeListener); ret.add(textField); textField.setPreferredSize(new Dimension(200, 28)); ret.add(createBrowseButton(directoriesOnly, browserApproveButtonText, textField, fileFilters)); return ret.toArray(new JComponent[ret.size()]); }
From source file:com.qmetry.qaf.automation.util.StringUtil.java
/** * Extract all numbers from given string. For example: extractNums( * "test123456.0012300 another number -201") will return array of Double * {123456.00123, -201.0}//from w w w . j a v a 2 s . c o m * * @param s * @return array of numbers */ public static Double[] extractNums(String s) { ArrayList<Double> lst = new ArrayList<Double>(); Pattern p = Pattern.compile("-?\\d+.?\\d+"); Matcher m = p.matcher(s); while (m.find()) { lst.add(Double.parseDouble(m.group())); } return lst.toArray(new Double[lst.size()]); }
From source file:com.intellij.plugins.haxe.ide.hierarchy.HaxeHierarchyUtils.java
/** * Retrieve the list of classes implemented in the given File. * * @param psiRoot - File to search.// w w w. j ava 2 s . c o m * @return An array of found classes, or an empty array if none. */ public static HaxeClass[] getClassList(@NotNull HaxeFile psiRoot) { ArrayList<HaxeClass> classes = new ArrayList<HaxeClass>(); for (PsiElement child : psiRoot.getChildren()) { if (child instanceof HaxeClass) { classes.add((HaxeClass) child); } } HaxeClass[] return_type = {}; return (classes.toArray(return_type)); }
From source file:Main.java
public static String[] splitToPairs(String Line) { Line = Line.replace(" + ", ", "); ArrayList<String> result = new ArrayList<>(); boolean foundQwote = false; String pair = ""; for (int idx = 0; idx < Line.length(); idx++) { if (Line.charAt(idx) == '"') { foundQwote = !foundQwote;/*from w w w .j ava2s . c o m*/ } else if (Line.charAt(idx) == ',') { if (!foundQwote) { result.add(pair.trim()); pair = ""; } else { pair = pair + Line.charAt(idx); } } else { pair = pair + Line.charAt(idx); } } result.add(pair.trim()); return result.toArray(new String[result.size()]); }
From source file:de.arago.portlet.util.UserContainer.java
public static String[] getUserRoles(String userId) { if (userId == null || userId.isEmpty()) return new String[0]; ArrayList<String> result = new ArrayList<String>(); try {/* w ww . j a va 2s. c o m*/ List<Role> roles = RoleLocalServiceUtil.getUserRoles(Long.valueOf(userId, 10)); for (Role g : roles) { result.add(g.getName()); } } catch (Exception ex) { Logger.getLogger(SecurityHelper.class.getName()).log(Level.SEVERE, null, ex); } return result.toArray(new String[0]); }
From source file:com.acme.spring.hibernate.Deployments.java
/** * <p>Retrieves the dependencies.</p> * * @return the array of the dependencies *//*from ww w. j a v a2s . com*/ 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")); files.addAll(resolveDependencies("org.hibernate:hibernate-core:3.6.0.Final")); files.addAll(resolveDependencies("org.hibernate:hibernate-annotations:3.4.0.GA")); files.addAll(resolveDependencies("javassist:javassist:3.6.0.GA")); return files.toArray(new File[files.size()]); }
From source file:org.ambraproject.migration.BootstrapMigratorServiceImpl.java
private static String[] getSQLCommands(String filename) throws IOException { String sqlString = getSQLScript(filename); ArrayList<String> sqlCommands = new ArrayList<String>(); String sqlCommandsTemp[] = sqlString.split(";"); for (String sqlCommand : sqlCommandsTemp) { if (sqlCommand.trim().length() > 0) { sqlCommands.add(sqlCommand); }/*from w ww .j a va 2 s. co m*/ } return sqlCommands.toArray(new String[0]); }
From source file:com.github.chenxiaolong.dualbootpatcher.patcher.PatcherUtils.java
public synchronized static Device[] getDevices(Context context) { ThreadUtils.enforceExecutionOnNonMainThread(); initializePatcher(context);//www .jav a 2s . c om if (sDevices == null) { File path = new File(getTargetDirectory(context) + File.separator + "devices.json"); try { String json = org.apache.commons.io.FileUtils.readFileToString(path, Charsets.UTF_8); Device[] devices = Device.newListFromJson(json); ArrayList<Device> validDevices = new ArrayList<>(); if (devices != null) { for (Device d : devices) { if (d.validate() == 0) { validDevices.add(d); } } } if (!validDevices.isEmpty()) { sDevices = validDevices.toArray(new Device[validDevices.size()]); } } catch (IOException e) { Log.w(TAG, "Failed to read " + path, e); } } return sDevices; }
From source file:Main.java
public static String[] GetSupportedFileSystems() { try {//from w ww.j a v a2 s . co m FileInputStream fProcFS = new FileInputStream(new File("/proc/filesystems")); ArrayList<String> filesystems = new ArrayList<String>(); byte[] data1 = new byte[1024]; int len = fProcFS.read(data1); fProcFS.close(); String fs = new String(data1, 0, len); if (fs.contains("rfs")) filesystems.add("rfs"); if (fs.contains("jfs")) filesystems.add("jfs"); if (fs.contains("ext2")) filesystems.add("ext2"); if (fs.contains("ext3")) filesystems.add("ext3"); if (fs.contains("ext4")) filesystems.add("ext4"); String[] List = (String[]) filesystems.toArray(new String[filesystems.size()]); return List; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }