Hello,
I have been looking for a method allowing me to convert a String[] into
a List.
As I could not find it on ArrayUtils, here is a small piece of code I
wrote :

    /**
     * Converts a <code>String[]</code> into a <code>List</code>.
     * @param array the <code>String[]</code> to convert.
     * @return <code>null</code> if the reference provided is
<code>null</code>, otherwise a <code>List</code> with the content of the
array's elements.
     */
    public static List<String> convertArrayToList(String[] array)
    {
        if (array==null)
            return null;
       
        List<String> list = new ArrayList<String>(array.length);
        for (int i = 0; i < array.length; i++) {
            list.add(array[i]);
        }
       
        return list;
    }

This is provided "as is" under the following licence :
http://www.apache.org/licenses/

Enjoy,

\T,


-- 
Thomas Lionel SMETS, CISSP (385434)
*m :* +32 497 44 68 12
*ph :* +32 2 852 3341
*skype :* thomas.lionel.smets

PGP = FDF0 8FB8 4F37 3F79 1011 05AB 0DCE 9BAB 5DD0 0E10

<<attachment: tsmets.vcf>>

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to