Here you can find the source of getUnionStr(String[] strAry, String unionChar, String appendChar)
public static String getUnionStr(String[] strAry, String unionChar, String appendChar)
//package com.java2s; /* //from w ww. j a v a 2 s . co m * @(#)StringUtil.java 1.0 2004-10-11 * * Copyright 2005 UFIDA Software Co. Ltd. All rights reserved. * UFIDA PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import java.util.Iterator; public class Main { public static String getUnionStr(String[] strAry, String unionChar, String appendChar) { StringBuffer ret = new StringBuffer(); for (int i = 0; i < strAry.length; i++) { if (i != 0) ret.append(unionChar); ret.append(appendChar + strAry[i] + appendChar); } return ret.toString(); } public static String toString(Object[] arr) { return toString(arr, ","); } @SuppressWarnings("unchecked") public static String toString(Object value, String delim) { if (value instanceof String) { return (String) value; } else { if (value.getClass().isArray()) { return toString((Object[]) value, delim); } else if (value instanceof Iterable) { return toString((Iterable) value, delim); } else { return value.toString(); } } } @SuppressWarnings("unchecked") public static String toString(Iterable c, String delim, String prefix, String suffix) { if (c == null) { return "null"; } StringBuffer sb = new StringBuffer(); Iterator it = c.iterator(); int i = 0; while (it.hasNext()) { if (i++ > 0) { sb.append(delim); } sb.append(prefix + it.next() + suffix); } return sb.toString(); } @SuppressWarnings("unchecked") public static String toString(Iterable c, String delim) { return toString(c, delim, "", ""); } public static String toString(Object value) { return toString(value, ","); } public static String toString(Object[] arr, String delim) { if (arr == null) { return "null"; } else { StringBuffer sb = new StringBuffer(); for (int i = 0; i < arr.length; i++) { if (i > 0) sb.append(delim); sb.append(arr[i]); } return sb.toString(); } } }