Here you can find the source of convertListToString(List
public static String convertListToString(List<String> itemList, String separator)
//package com.java2s; /*/*from w ww .ja va2s . c o m*/ * Copyright (C) 2006-2016 Talend Inc. - www.talend.com * * This source code is available under agreement available at * %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt * * You should have received a copy of the agreement along with this program; if not, write to Talend SA 9 rue Pages * 92150 Suresnes, France */ import java.util.List; public class Main { public static String convertListToString(List<String> itemList, String separator) { if (itemList == null) { return null; } StringBuilder result = new StringBuilder(); for (int i = 0; i < itemList.size(); i++) { result.append((i > 0) ? separator : ""); //$NON-NLS-1$ result.append(escape(itemList.get(i))); } return result.toString(); } public static String convertListToString(List<String> itemList) { if (itemList == null) { return null; } StringBuilder result = new StringBuilder(); for (int i = 0; i < itemList.size(); i++) { result.append((i > 0) ? ";" : ""); //$NON-NLS-1$ //$NON-NLS-2$ result.append(escapeSemicolon(itemList.get(i))); } return result.toString(); } public static String escape(String src) { int i; char j; StringBuffer tmp = new StringBuffer(); tmp.ensureCapacity(src.length() * 6); for (i = 0; i < src.length(); i++) { j = src.charAt(i); if (Character.isDigit(j) || Character.isLowerCase(j) || Character.isUpperCase(j)) { tmp.append(j); } else if (j < 256) { tmp.append("%"); //$NON-NLS-1$ if (j < 16) { tmp.append("0"); //$NON-NLS-1$ } tmp.append(Integer.toString(j, 16)); } else { tmp.append("%u"); //$NON-NLS-1$ tmp.append(Integer.toString(j, 16)); } } return tmp.toString(); } public static String escapeSemicolon(String src) { int i; char j; StringBuffer tmp = new StringBuffer(); tmp.ensureCapacity(src.length() * 6); for (i = 0; i < src.length(); i++) { j = src.charAt(i); if (';' == j || '%' == j) { if (j < 256) { tmp.append("%"); //$NON-NLS-1$ if (j < 16) { tmp.append("0"); //$NON-NLS-1$ } tmp.append(Integer.toString(j, 16)); } else { tmp.append("%u"); //$NON-NLS-1$ tmp.append(Integer.toString(j, 16)); } } else { tmp.append(j); } } return tmp.toString(); } }