Here you can find the source of getCommaSeparatedValue(Iterator
private static String getCommaSeparatedValue(Iterator<String> it)
//package com.java2s; /******************************************************************************* * Licensed Materials - Property of IBM//from w w w. j av a 2s . c o m * (c) Copyright IBM Corporation 2015. All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * Use, duplication or disclosure restricted by GSA ADP Schedule * Contract with IBM Corp. *******************************************************************************/ import java.util.Iterator; import java.util.List; import java.util.Map; public class Main { private static String getCommaSeparatedValue(Iterator<String> it) { boolean first = true; StringBuffer result = new StringBuffer(); while (it.hasNext()) { if (first) { first = false; } else { result.append(","); //$NON-NLS-1$ } result.append(it.next()); } return result.toString(); } public static String getCommaSeparatedValue(List<String> list) { if (isNullOrEmpty(list)) { return null; } return getCommaSeparatedValue(list.iterator()); } public static String getCommaSeparatedValue(Map<String, String> dataMap, String delimiter, String assigner) { if (dataMap == null || dataMap.size() == 0) { return null; } StringBuffer buf = new StringBuffer(""); //$NON-NLS-1$ for (Map.Entry<String, String> entry : dataMap.entrySet()) { buf.append(entry.getKey()).append(assigner).append(entry.getValue()).append(delimiter); } String value = buf.toString(); if (!value.isEmpty()) { value = value.substring(0, value.length() - 1); } else { value = null; } return value; } public static boolean isNullOrEmpty(String value) { return value == null || value.isEmpty(); } public static boolean isNullOrEmpty(List<?> list) { return list == null || list.isEmpty(); } public static boolean isNullOrEmpty(Map<String, String> value) { return value == null || value.isEmpty(); } }