Java List Join join(List list, String flag)

Here you can find the source of join(List list, String flag)

Description

join

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
public static String join(List list, String flag) 

Method Source Code

//package com.java2s;

import java.util.List;

public class Main {

    @SuppressWarnings("unchecked")
    public static String join(List list, String flag) {
        String res = "";
        if (list != null) {
            StringBuilder sb = new StringBuilder();
            int len = list.size();
            for (int i = 0; i < len; i++) {
                sb.append(flag);//  www.  j  a  va2 s.co  m
                sb.append(list.get(i));
            }
            res = sb.replace(0, 1, "").toString();
        }
        return res;
    }

    public static String replace(String str, String flag, String[] replaceAry) {
        if (str != null && replaceAry != null) {
            for (int i = 0; i < replaceAry.length; i++) {
                str = str.replaceFirst("\\" + flag, replaceAry[i]);
            }
        }
        return str;
    }

    public static String replace(String str) {
        return str.replaceAll("\n|\b|\r|\t|  |   |    ", "").replace("> <", "><");
    }
}

Related

  1. join(List items, String separator)
  2. join(List l, String sep)
  3. join(List list, char separator)
  4. join(List list, String delim)
  5. join(List list, String delimiter)
  6. join(List list, String separator)
  7. join(List list, String separator)
  8. join(List objects)
  9. join(List objects, String joiner)