Java Array Join join(String[] lines, String sep)

Here you can find the source of join(String[] lines, String sep)

Description

join

License

Open Source License

Declaration

public static String join(String[] lines, String sep) 

Method Source Code

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

import java.util.List;

public class Main {
    public static String join(String[] lines, String sep) {
        StringBuilder buf = new StringBuilder();
        if (lines != null)
            for (String line : lines) {
                if (buf.length() > 0) {
                    buf.append(sep);/*from  w w  w  .  ja va2  s .  c o m*/
                }
                buf.append(line);
            }
        return buf.toString();
    }

    public static String join(List<String> lines, String sep) {
        return join(lines.toArray(new String[0]), sep);
    }
}

Related

  1. join(String[] elements, String separator)
  2. join(String[] elements, String separator)
  3. join(String[] inputArray, String glueString)
  4. join(String[] items, String delimiter)
  5. join(String[] lines, String delim)
  6. join(String[] lines, String separator)
  7. join(String[] names, String sep)
  8. join(String[] parts, String separator)
  9. join(String[] sentence, String separator)