List of usage examples for java.util ArrayList toArray
@SuppressWarnings("unchecked") public <T> T[] toArray(T[] a)
From source file:com.dtolabs.rundeck.core.utils.ScriptExecUtil.java
/** * Create the environment array for executing via {@link Runtime}. *///w w w . j av a 2 s.co m private static String[] createEnvironmentArray(final Map<String, String> envMap) { final ArrayList<String> envlist = new ArrayList<String>(); for (final Map.Entry<String, String> entry : envMap.entrySet()) { envlist.add(entry.getKey() + "=" + entry.getValue()); } return envlist.toArray(new String[envlist.size()]); }
From source file:com.excelsiorjet.api.util.Utils.java
public static String[] prepend(String firstElement, String[] remaining) { if (remaining == null) { return new String[] { firstElement }; }/* w ww. j ava 2 s . c o m*/ ArrayList<String> res = new ArrayList<>(); res.add(firstElement); res.addAll(Arrays.asList(remaining)); return res.toArray(new String[remaining.length + 1]); }
From source file:io.github.jeremgamer.editor.panels.Labels.java
public static String[] getLabels() { ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < labelList.getModel().getSize(); i++) { list.add(labelList.getModel().getElementAt(i)); }//from w ww.j a va 2 s .c om return list.toArray(new String[0]); }
From source file:com.dtolabs.rundeck.core.cli.project.ProjectTool.java
static String[] removeExtendedProperties(String[] args) { final ArrayList<String> list = new ArrayList<String>(); for (final String s : args) { if (!isExtendedPropertyArg(s)) { list.add(s);// w w w. j a va 2 s . c o m } } return list.toArray(new String[list.size()]); }
From source file:io.github.jeremgamer.editor.panels.Buttons.java
public static String[] getButtons() { ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < buttonList.getModel().getSize(); i++) { list.add(buttonList.getModel().getElementAt(i)); }/*from ww w. j av a 2 s. c om*/ return list.toArray(new String[0]); }
From source file:csv.FileManager.java
static public void writeItems(String fileName, ArrayList<ArrayList<String>> data) { try {//from w w w. ja v a 2s.co m BufferedWriter out = new BufferedWriter(new FileWriter(fileName)); CSVWriter writer = new CSVWriter(out); String[] t = new String[0]; for (ArrayList<String> row : data) { boolean found = false; for (String str : row) { if (!str.isEmpty()) { found = true; } } if (found) writer.writeNext(row.toArray(t)); } out.close(); } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:gov.noaa.pfel.coastwatch.pointdata.MakeErdJavaZip.java
/** * This makes cwhdfToNc.zip specifically for LAS. * * unzip with: unzip cwhdfToNc.zip /*from w ww .j a v a2 s .com*/ */ public static void makeCwhdfToNcZip() throws Exception { String2.log("\n*** makeCwhdfToNcZip"); String errorInMethod = String2.ERROR + " while generating cwhdfToNc.zip:\n"; //delete the zip file String zipName = "c:/backup/cwhdfToNc.zip"; //accumulate the file names to be zipped String baseDir = "c:/content/"; ArrayList<String> dirNames = new ArrayList(); String2.add(dirNames, RegexFilenameFilter.recursiveFullNameList(baseDir + "cwhdfToNc/", ".+", false)); //convert to sorted String array String dirNameArray[] = dirNames.toArray(new String[0]); Arrays.sort(dirNameArray); //String2.log(String2.toNewlineString(dirNameArray)); //make the zip file String2.log("MakeCwhdfToNcZip is making " + zipName); File2.delete(zipName); SSR.zip(zipName, dirNameArray, 60, baseDir); String2.log("\nMakeCwhdfToNcZip successfully finished making " + zipName + ".\nnFiles=" + dirNames.size()); }
From source file:com.baystep.jukeberry.JsonConfiguration.java
public static String[] getStringArray(JSONObject obj, String key) { ArrayList<String> list = new ArrayList<>(); JSONArray array = (JSONArray) obj.get(key); if (array != null) { for (int i = 0; i < array.size(); i++) { list.add(array.get(i).toString()); }/* w w w . jav a2 s . c om*/ } String[] output = new String[list.size()]; list.toArray(output); return output; }
From source file:com.indeed.imhotep.index.builder.util.SmartArgs.java
/** * parse a String into an argument list, in the same way java parses * arguments passed to main()/* w ww .ja va 2 s .co m*/ */ public static String[] parseArgParams(String line) { StreamTokenizer tok = new StreamTokenizer(new StringReader(line)); tok.resetSyntax(); tok.wordChars('\u0000', '\uFFFF'); tok.whitespaceChars(' ', ' '); tok.quoteChar('\"'); ArrayList<String> output = new ArrayList<String>(); try { while (tok.nextToken() != StreamTokenizer.TT_EOF) { output.add(tok.sval); } } catch (IOException e) { } return output.toArray(new String[output.size()]); }
From source file:fr.kwiatkowski.ApkTrack.UpdateSource.java
/** * Returns the name of all the update sources available for a given package. * @param app The app we want to check against. * @param ctx The context of the application * @return A list of names for UpdateSources that can be used to check the application's version. *//*from w w w .j a v a2 s .c om*/ public static String[] getSources(InstalledApp app, Context ctx) { ArrayList<String> res = new ArrayList<String>(); for (UpdateSource s : getUpdateSources(ctx)) { if (s.isApplicable(app)) { res.add(s.getName()); } } String[] retval = new String[res.size()]; res.toArray(retval); return retval; }