public static void putArray(Map<String,String> properties,String key,String[] array,String separator){
  if (array == null || array.length == 0) {
    properties.remove(key);
  }
 else {
    StringBuilder concat=new StringBuilder();
    for (int i=0; i < array.length; i++) {
      String value=array[i];
      if (value != null && value.length() > 0) {
        if (value.contains(separator)) {
          throw new IllegalArgumentException("array contains an element '" + value + "' that contains the separator '"+ separator+ "'");
        }
        concat.append(value);
        if (i < array.length - 1) {
          concat.append(separator);
        }
      }
    }
    properties.put(key,concat.toString());
  }
}

public static void putArray ( Map < String , String > properties , String key , String [ ] array , String separator ) { if ( array == null || array . length == 0 ) { properties . remove ( key ) ; } else { StringBuilder concat = new StringBuilder ( ) ; for ( int i = 0 ; i < array . length ; i ++ ) { String value = array [ i ] ; if ( value != null && value . length ( ) > 0 ) { if ( value . contains ( separator ) ) { throw new IllegalArgumentException ( "array contains an element '" + value + "' that contains the separator '" + separator + "'" ) ; } concat . append ( value ) ; if ( i < array . length - 1 ) { concat . append ( separator ) ; } } } properties . put ( key , concat . toString ( ) ) ; } }
concatenates the specified array into a combined string using the specified separator and puts the result as a value into the specified properties with the specified key . the values in the array must not contain the separator otherwise an illegalargumentexception is raised . null or empty arrays will remove the key from the properties map
