Java List Join stringJoin(List list, String sep)

Here you can find the source of stringJoin(List list, String sep)

Description

string Join

License

BSD License

Declaration

public static String stringJoin(List<String> list, String sep) 

Method Source Code

//package com.java2s;
//The contents of this file are subject to the "Simplified BSD License" (the "License");

import java.util.List;

public class Main {
    public static String stringJoin(List<String> list, String sep) {
        if (list == null)
            return null;

        StringBuilder sb = new StringBuilder();

        for (String s : list) {
            if (sb.length() > 0)
                sb.append(sep);/*  w  w w.  j a va2 s . c  o m*/
            sb.append(s);
        }
        return sb.toString();

    }
}

Related

  1. orderJoinType(List jList)
  2. reverseJoinType(List jList)
  3. sortAndJoin(List col, String sep)
  4. sortAndJoin(List list)
  5. stringJoin(List list, String separator)
  6. trimAndJoin(List values, String delimiter)

    HOME | Copyright © www.java2s.com 2016