Converts the given list to a comma separated string to be used with email address field - Android java.util

Android examples for java.util:List Convert

Description

Converts the given list to a comma separated string to be used with email address field

Demo Code


//package com.book2s;

import java.util.ArrayList;

public class Main {
    /**/*w  w w  .  j a  va 2  s.c  o  m*/
     * <p>Converts the given list to a comma separated string to be used with email address field</p>
     *
     * @param stringList a list of strings to be converted to CSV format
     * @return a comma separated string representation of the given list
     */
    public static String formatListToCSV(ArrayList<String> stringList) {
        String formattedContactList = "";
        for (String contactName : stringList) {
            formattedContactList += contactName + ";";
        }
        if (formattedContactList.length() > 0) {
            formattedContactList = formattedContactList.substring(0,
                    formattedContactList.length() - 1);
        }
        return formattedContactList;
    }
}

Related Tutorials