Here you can find the source of appendArray(StringBuilder sb, T[] array, String delimiter)
array
to buffer, separated by delimiter
Parameter | Description |
---|---|
T | Type of elements stored in <code>array</code> |
sb | StringBuilder to be modified |
array | Array of elements |
delimiter | Delimiter to separate elements |
sb
to allow chaining
public static <T> StringBuilder appendArray(StringBuilder sb, T[] array, String delimiter)
//package com.java2s; //License from project: LGPL public class Main { /**//from ww w .j a v a2s . co m * Appends all elements of <code>array</code> to buffer, separated by delimiter * @param <T> Type of elements stored in <code>array</code> * @param sb StringBuilder to be modified * @param array Array of elements * @param delimiter Delimiter to separate elements * @return Modified <code>sb</code> to allow chaining */ public static <T> StringBuilder appendArray(StringBuilder sb, T[] array, String delimiter) { boolean firstRun = true; for (T elem : array) { if (!firstRun) sb.append(delimiter); else firstRun = false; sb.append(elem.toString()); } return sb; } }