Java String Join join(String delimiter, String... items)

Here you can find the source of join(String delimiter, String... items)

Description

join

License

Open Source License

Declaration

public static String join(String delimiter, String... items) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Arrays;

import java.util.List;

public class Main {
    public static String join(String delimiter, String... items) {
        return join(delimiter, Arrays.asList(items));
    }/*from   w w w  . ja v  a2 s. c o m*/

    public static String join(String delimiter, List<? extends Object> items) {
        StringBuilder buffer = new StringBuilder();

        if (items != null && items.size() > 0) {
            buffer.append(items.get(0));

            for (int i = 1; i < items.size(); i++) {
                buffer.append(delimiter).append(items.get(i).toString());
            }
        }

        return buffer.toString();
    }
}

Related

  1. join(String delimiter, Iterable elements)
  2. join(String delimiter, Iterable strings)
  3. join(String delimiter, Iterable strings)
  4. join(String delimiter, Object... objects)
  5. join(String delimiter, Object... parts)
  6. join(String delimiter, String... params)
  7. join(String delimiter, String... strings)
  8. join(String delimiter, T... array)
  9. join(String glue, Iterable items)