Java List Join joinAndQuote(char joinChar, char quoteChar, List strings)

Here you can find the source of joinAndQuote(char joinChar, char quoteChar, List strings)

Description

join And Quote

License

Open Source License

Declaration

public static String joinAndQuote(char joinChar, char quoteChar, List<String> strings) 

Method Source Code

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

import java.util.List;

public class Main {
    public static String joinAndQuote(char joinChar, char quoteChar, List<String> strings) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < strings.size(); ++i) {
            sb.append(quoteChar);/*  w w  w.j  av  a  2s. c o  m*/
            sb.append(strings.get(i));
            if (i + 1 < strings.size()) {
                sb.append(joinChar);
            }
            sb.append(quoteChar);
        }
        return sb.toString();
    }

    public static String joinAndQuote(char joinChar, char quoteChar, String[] strings) {
        if (strings == null) {
            return "";
        }

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < strings.length; ++i) {
            sb.append(quoteChar);
            sb.append(strings[i]);
            if (i + 1 < strings.length) {
                sb.append(joinChar);
            }
            sb.append(quoteChar);
        }
        return sb.toString();
    }
}

Related

  1. join(String sign, List src)
  2. join(String[] elementList, String separator)
  3. join(String[] list, String separator)
  4. join(T delimiter, List list)
  5. join(T element, List otherElements)
  6. joinArray(List list, String separator)
  7. joinArrayString(List values)
  8. joinColumnArray(List columnArray)
  9. joinCommaAnd(List objs)