Here you can find the source of createCommaList(List> values, int rowCharacterCount)
Parameter | Description |
---|---|
values | The values to handle as simple String |
rowCharacterCount | The row character number what will indicate the new line should be added |
public static String createCommaList(List<?> values, int rowCharacterCount)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { /**/*from w ww . ja v a 2 s. c om*/ * Gets the comma list for given values. * * @param values The values to handle as simple String * @param rowCharacterCount The row character number what will indicate the new line should be added * @return The comma list for given values */ public static String createCommaList(List<?> values, int rowCharacterCount) { StringBuffer lSB = new StringBuffer(); StringBuffer lRowSB = new StringBuffer(); int liValuesCount = values.size(); int li = 0; for (Object lValue : values) { lRowSB.append(lValue.toString()); if (li < liValuesCount - 1) { lRowSB.append(", "); } if (lRowSB.length() > rowCharacterCount) { lSB.append(lRowSB); lSB.append("\r\n"); lRowSB = new StringBuffer(); } li++; } lSB.append(lRowSB); return lSB.toString(); } /** * Gets the comma list for given values. * * @param values The values to handle as simple String * @return The comma list for given values */ public static String createCommaList(List<?> values) { StringBuffer lSB = new StringBuffer(); if (values != null) { for (Object lValue : values) { lSB.append(lValue.toString()); lSB.append(", "); } if (lSB.length() > 0) { lSB.delete(lSB.length() - 2, lSB.length() - 1); } } return lSB.toString(); } }