List of utility methods to do Collection to Array
Object[] | toArray(T arrayOrCollection) to Array if (arrayOrCollection instanceof Collection) { return ((Collection) arrayOrCollection).toArray(); } else { return (Object[]) arrayOrCollection; |
int[] | toArrayInt(Collection Returns the values of a Integer Collection as array. int[] retvals = new int[integerCollection.size()]; int ii = 0; for (Integer iValue : integerCollection) { retvals[ii++] = iValue; return retvals; |
char[][] | toArrays(Collection to Arrays char[][] arr = new char[strings.size()][]; int i = 0; for (String str : strings) { arr[i++] = str.toCharArray(); return arr; |
String[] | toArrayString(Collection> col, boolean spacing) to Array String int size = col.size(); if (spacing) { size++; String[] result = new String[size]; int i = 0; if (spacing) { result[i++] = ""; ... |
Collection | toBaseTypedCollection(Collection extends T> initial) Workaround for compile time checking of list types. return (Collection<T>) initial;
|
byte[] | toByteArray(Collection extends Number> c) to Byte Array byte arr[] = new byte[c.size()]; int i = 0; for (Number item : c) arr[i++] = item.byteValue(); return arr; |
byte[] | toByteArray(Collection Converts a Collection of Bytes into a byte[] array. int pos = 0; byte byteArray[] = new byte[c.size()]; for (Byte id : c) byteArray[pos++] = id; return byteArray; |
char[] | toCharArray(Collection to Char Array char[] result = new char[source.size()]; int i = 0; for (Character c : source) result[i++] = c; return result; |
List | toCharArray(Collection to Char Array List<char[]> charpatterns = new ArrayList<char[]>(patterns.size()); for (String pattern : patterns) { charpatterns.add(pattern.toCharArray()); return charpatterns; |
Class>[] | toClassArray(Collection Copy the given Collection into a Class array. if (collection == null) { return null; return collection.toArray(new Class<?>[collection.size()]); |