List of usage examples for java.util List toArray
<T> T[] toArray(T[] a);
From source file:libra.core.Core.java
private static String[] removeRunMode(String[] args) { List<String> param = new ArrayList<String>(); for (String arg : args) { if (!arg.equalsIgnoreCase("map") && !arg.equalsIgnoreCase("reduce")) { param.add(arg);/*w ww.j a va 2 s . co m*/ } } return param.toArray(new String[0]); }
From source file:edu.byu.nlp.stats.DirichletTestUtils.java
public static double[][][] sampleDirichletMultinomialMatrixDataset(double diagonalAlpha, double offdiagonalAlpha, int matrixSize, int numDataPoints, int datumSize, RandomGenerator rnd) { double[][] alpha = new double[matrixSize][matrixSize]; for (int r = 0; r < matrixSize; r++) { for (int c = 0; c < matrixSize; c++) { alpha[r][c] = (r == c) ? diagonalAlpha : offdiagonalAlpha; }/*from w w w. jav a 2s . c o m*/ } List<double[][]> result = Lists.newArrayList(); for (int i = 0; i < numDataPoints; i++) { result.add(sampleDirichletMultinomialMatrixDataset(alpha, datumSize, rnd)); } return result.toArray(new double[0][0][0]); }
From source file:Money.java
public static Money add(List moneys) { Money[] arr = (Money[]) moneys.toArray(new Money[moneys.size()]); return add(arr); }
From source file:com.yahoo.sshd.tools.artifactory.Checksum.java
public static Checksum[] build(LinkedHashMap<String, String> checksums) { if (null == checksums) { return null; }//w w w .j a v a 2s. com List<Checksum> list = new LinkedList<>(); for (Entry<String, String> e : checksums.entrySet()) { list.add(new Checksum(e.getKey(), e.getValue())); } return list.toArray(new Checksum[] {}); }
From source file:com.link_intersystems.lang.reflect.ThreadLocalProxy.java
@SuppressWarnings("unchecked") public static <T, TC> T createProxy(ThreadLocal<T> threadLocal, T nullInstance, Class<TC> targetClass) { List<Class<?>> allInterfaces = new ArrayList<Class<?>>(ClassUtils.getAllInterfaces(targetClass)); if (targetClass.isInterface()) { allInterfaces.add(targetClass);/* w w w . j av a2s . c o m*/ } Class<?>[] interfaces = (Class<?>[]) allInterfaces.toArray(new Class<?>[allInterfaces.size()]); T proxy = (T) Proxy.newProxyInstance(targetClass.getClassLoader(), interfaces, new ThreadLocalProxy(threadLocal, nullInstance)); return proxy; }
From source file:com.google.gerrit.server.project.SectionSortCache.java
private static AccessSection[] copy(List<AccessSection> sections) { return sections.toArray(new AccessSection[sections.size()]); }
From source file:libra.preprocess.Preprocessor.java
private static String[] removeRunStages(String[] args) { List<String> param = new ArrayList<String>(); for (String arg : args) { if (!arg.equalsIgnoreCase("stage1") && !arg.equalsIgnoreCase("stage2")) { param.add(arg);//from w ww .j a v a2s .c o m } } return param.toArray(new String[0]); }
From source file:StringUtil.java
/** * Parses a list according to the specified delimiter into an * array of Strings./* w w w. j a v a 2 s. co m*/ * @see java.util.StringTokenizer * @param list a string of token seperated values * @param delim the delimiter character(s). Each character in the string is a * single delimeter. * @return an array of strings */ public static String[] parseList(String list, String delim) { List result = new ArrayList(); StringTokenizer tokenizer = new StringTokenizer(list, delim); while (tokenizer.hasMoreTokens()) { result.add(tokenizer.nextToken()); } return (String[]) result.toArray(new String[0]); }
From source file:Main.java
/** * Loads lines of text from the given path in the assets directory. * @param context Application context.//ww w.j ava 2 s .c om * @param path Path in the assets folder to the text file to load. * @return String array representing lines of text in the file. */ public static String[] loadTextFromAssets(Context context, String path) { try { // Open the input stream to the text in assets InputStream inputStream = context.getAssets().open(path); InputStreamReader inputStreamReader = new InputStreamReader(inputStream); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); List<String> lines = new ArrayList<String>(); String line; while ((line = bufferedReader.readLine()) != null) { lines.add(line); } inputStream.close(); return lines.toArray(new String[lines.size()]); } catch (IOException e) { return null; } }
From source file:com.silverpeas.ical.FeedUtilities.java
private static final SyndEntry[] getFeedEntries(SyndFeed feed) throws Exception { List list = feed.getEntries(); SyndEntry[] entries = new SyndEntry[list.size()]; list.toArray(entries); return entries; }