Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { static String tocsv(int[] arr) { final StringBuffer buf = new StringBuffer(); final int count = arr.length; if (count > 0) { buf.append(arr[0]); } for (int i = 1; i < count; ++i) { buf.append(","); buf.append(arr[i]); } return buf.toString(); } static String tocsv(String[] arr) { final StringBuffer buf = new StringBuffer(); final int count = arr.length; if (count > 0) { buf.append(arr[0]); } for (int i = 1; i < count; ++i) { buf.append(","); buf.append(arr[i]); } return buf.toString(); } static String tocsv(Iterable<String> set) { Iterator<String> iter = set.iterator(); StringBuffer buf = new StringBuffer(); if (iter.hasNext()) { buf.append(iter.next()); } while (iter.hasNext()) { buf.append(","); buf.append(iter.next()); } return buf.toString(); } }