Java Array Join join(String[] arrayOfString)

Here you can find the source of join(String[] arrayOfString)

Description

join

License

Open Source License

Declaration

public static String join(String[] arrayOfString) 

Method Source Code

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

import java.util.*;

public class Main {
    public static String join(Collection c) {
        StringBuilder builder = new StringBuilder();
        Iterator itr = c.iterator();
        while (itr.hasNext()) {
            builder.append(itr.next());//from ww w.  j a  v a2s. c  om
        }
        return builder.toString();
    }

    public static String join(String[] arrayOfString) {
        return join(arrayOfString, null);
    }

    public static String join(String[] arrayOfString, String separator) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < arrayOfString.length; i++) {
            builder.append(arrayOfString[i]);
            if (separator != null && i != arrayOfString.length - 1)
                builder.append(separator);
        }
        return builder.toString();
    }
}

Related

  1. join(String[] array, String delimiter)
  2. join(String[] array, String sep)
  3. join(String[] array, String separator)
  4. join(String[] array, String separator)
  5. join(String[] array, String separator)
  6. join(String[] datalines)
  7. join(String[] elements, String separator)
  8. join(String[] elements, String separator)
  9. join(String[] inputArray, String glueString)