List of usage examples for java.util List toArray
<T> T[] toArray(T[] a);
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T[] toArray(List<T> list, Class<T> componentType) { return list.toArray((T[]) Array.newInstance(componentType, list.size())); }
From source file:net.eledge.android.toolkit.StringArrayUtils.java
public static String[] toArray(List<String> list) { if (list != null) { return list.toArray(new String[list.size()]); }// w w w . j a v a 2 s. com return new String[] {}; }
From source file:Main.java
public static List[] cartesianProduct(List left, List[] right) { if (right.length == 0) { return (List[]) left.toArray(new List[] {}); }//from www .j av a 2 s . c o m List result = new ArrayList(); for (Object elementLeft : left) { for (Object elementRight : right[0]) { List resultElement = new ArrayList(); if (elementLeft instanceof List) { resultElement = new ArrayList((List) elementLeft); } else { resultElement.add(elementLeft); } resultElement.add(elementRight); result.add(resultElement); } } return cartesianProduct(result, Arrays.asList(right).subList(1, right.length).toArray(new List[] {})); }
From source file:ddf.security.permission.Permissions.java
public static Map<String, Set<String>> parsePermissionsFromString(List<String> permStrings) { return parsePermissionsFromString(permStrings.toArray(new String[permStrings.size()])); }
From source file:Main.java
/** * Returns an array of aList items in the same order than the {@link List}. * * @param aList/*from ww w . ja v a2 s. co m*/ * {@link List} to transform. * * @return {@link T[]} array of aList items in the same order than the {@link List}. * * @since 1 */ public static <T> T[] toArray(List<T> aList) { T[] result = (T[]) Array.newInstance(aList.get(0).getClass(), 2); result = aList.toArray(result); return result; }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T[] toArray(List<?> list, Class<T> type) { T[] array = (T[]) Array.newInstance(type, list.size()); return list.toArray(array); }
From source file:de.weltraumschaf.registermachine.convert.ByteArray.java
/** * Converts a list of boxed bytes to an array of native bytes. * * @param original list of boxed bytes/* ww w.j a v a 2 s . c o m*/ * @return array of native bytes */ public static byte[] convertToNativeArray(final List<Byte> original) { final List<Byte> in = Lists.newArrayList(original); return ByteArray.toNative(in.toArray(new Byte[in.size()])); }
From source file:com.navercorp.pinpoint.common.server.util.InetAddressUtils.java
public static InetAddress[] toInetAddressArray(List<String> addressList) { final List<InetAddress> inetList = InetAddressUtils.toInetAddressList(addressList); return inetList.toArray(new InetAddress[0]); }
From source file:common.Util.java
public static String join(List<String> strs, String sep) { return join(strs.toArray(new String[strs.size()]), sep); }
From source file:com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientRegistrar.java
/** * Converts the list into the array./*from w w w .j a va2 s .c om*/ * * @param list the list * @return the array */ private static String[] toArray(List<String> list) { return list.toArray(new String[list.size()]); }