Here you can find the source of arrayToDelimitedString(Object[] arr, String delim)
Parameter | Description |
---|---|
arr | array to display. Elements may be of any type (toString() will be called on each element). |
delim | delimiter to use (probably a ,) |
public static String arrayToDelimitedString(Object[] arr, String delim)
//package com.java2s; //License from project: Apache License public class Main { /**//from w w w .j a va 2 s.c o m * Convenience method to return a String array as a delimited (e.g. CSV) * String. Useful for toString() implementations * @param arr array to display. Elements may be of any type (toString() will be * called on each element). * @param delim delimiter to use (probably a ,) */ public static String arrayToDelimitedString(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(); } } }