mail address Array To String - Java java.lang

Java examples for java.lang:String Array

Description

mail address Array To String

Demo Code


//package com.java2s;

import java.util.Arrays;

import java.util.List;

import javax.mail.Address;

import javax.mail.internet.InternetAddress;

public class Main {
    public static String addrArrToStr(InternetAddress[] addrs) {
        return addrArrToStr(Arrays.asList(addrs));
    }// w  w w . ja va 2 s  . c  o  m

    public static String addrArrToStr(List<InternetAddress> addrs) {
        if (addrs == null)
            return "";
        StringBuffer sb = new StringBuffer();
        for (Address a : addrs) {
            sb.append(sb.length() > 0 ? ", " : "");
            sb.append(a.toString());
        }
        return sb.toString();
    }
}

Related Tutorials