Example usage for java.util List toArray

List of usage examples for java.util List toArray

Introduction

In this page you can find the example usage for java.util List toArray.

Prototype

<T> T[] toArray(T[] a);

Source Link

Document

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

Usage

From source file:com.facebook.stetho.dumpapp.DumpappHandler.java

protected static String[] getArgs(HttpRequest request) {
    Uri requestUri = Uri.parse(request.getRequestLine().getUri());
    List<String> argsList = requestUri.getQueryParameters(QUERY_PARAM_ARGV);
    return argsList.toArray(new String[argsList.size()]);
}

From source file:com.lithium.flow.util.CsvFormats.java

@Nullable
public static String[] getHeader(@Nonnull Config config, @Nonnull String key) {
    if (!config.containsKey(key)) {
        return null;
    } else {/*w  w w .  ja v  a  2 s  . c  om*/
        List<String> headers = config.getList(key);
        return headers.toArray(new String[headers.size()]);
    }
}

From source file:Main.java

public static Date[] toDateArray(List<Date> list) {
    if (isEmpty(list)) {
        return new Date[0];
    }/*  w ww  .j  a  va 2s.c o  m*/
    Date[] array = new Date[list.size()];
    return list.toArray(array);
}

From source file:Main.java

public static Integer[] getDigits(String number) {
    List<Integer> digits = new ArrayList<Integer>();
    for (int i = 0; i < number.length(); i++) {
        int j = Character.digit(number.charAt(i), 10);
        digits.add(j);/* w  w w  . j av a 2s  .c om*/
    }
    return digits.toArray(new Integer[] {});
}

From source file:Main.java

public static String[] toStringArray(List<String> list) {
    if (isEmpty(list)) {
        return new String[] {};
    }/*from w w w  .j  a  va2  s . com*/
    int size = list.size();
    String[] strs = list.toArray(new String[size]);
    return strs;
}

From source file:Main.java

/**
 * Concatenates two arrays./* ww  w  .ja  v  a  2  s  .co m*/
 * 
 * @param array1
 *            - first array
 * @param array2
 *            - second array
 * @param <T>
 *            - object class
 * @return array contatenation
 */
public static <T> T[] concatenate2Arrays(T[] array1, T... array2) {
    List<T> result = new ArrayList<T>();
    result.addAll(Arrays.asList(array1));
    result.addAll(Arrays.asList(array2));

    return result.toArray(array1);
}

From source file:edu.harvard.i2b2.crc.datavo.CRCJAXBUtil.java

public static JAXBUtil getJAXBUtil() {
    if (jaxbUtil == null) {
        BeanFactory springBean = QueryProcessorUtil.getInstance().getSpringBeanFactory();
        List jaxbPackageName = (List) springBean.getBean("jaxbPackage");
        String[] jaxbPackageNameArray = (String[]) jaxbPackageName.toArray(new String[] {

        });/*from   w ww . j  a  v a2 s .  c  om*/
        jaxbUtil = new JAXBUtil(jaxbPackageNameArray);
    }

    return jaxbUtil;
}

From source file:Main.java

public static String[] toStringArray(List<String> list) {
    if (isEmpty(list)) {
        return new String[0];
    }/* www .j  a va  2s. c o m*/
    String[] array = new String[list.size()];
    return list.toArray(array);
}

From source file:ext.sns.config.ConfigManager.java

/**
 * ?????/* w w w.  j  a  va  2 s  .  c  om*/
 * 
 * @param typeList ???
 * 
 * @return ?????
 */
public static List<String> getProviderNameByTypes(List<String> typeList) {
    return getProviderNameByTypes(typeList.toArray(new String[0]));
}

From source file:Main.java

public static String[] getExtendedKeyUsage(X509Certificate certificate) throws IOException {
    try {/*  w w  w .  j a v a  2s  . c  o  m*/
        List<String> eku = certificate.getExtendedKeyUsage();
        if (eku == null) {
            return null;
        }
        return eku.toArray(new String[0]);
    } catch (GeneralSecurityException gse) {
        throw new IOException(gse);
    }
}