Here you can find the source of convertArrayToString(String[] fields, String delimiter)
public static String convertArrayToString(String[] fields, String delimiter)
//package com.java2s; //License from project: Mozilla Public License public class Main { public static final String[] delimiters = { ";", "|", "~" }; public static String convertArrayToString(String[] fields, String delimiter) {//from w w w. ja v a2 s. c o m StringBuilder csvStringBuilder = new StringBuilder(); for (int i = 0; i < fields.length; i++) { if (i > 0) { csvStringBuilder.append(delimiter); } csvStringBuilder.append(fields[i]); } return csvStringBuilder.toString(); } public static String convertArrayToString(String[] fields) { int delimIndex = 0; StringBuilder stringBuilder = new StringBuilder(); for (String dl : delimiters) { for (String f : fields) { if (f.contains(dl)) { stringBuilder = new StringBuilder(); break; } else { stringBuilder.append(delimiters[delimIndex]).append(f); } } } return stringBuilder.toString(); } }