Here you can find the source of join(String[] array)
Parameter | Description |
---|---|
array | a parameter |
public static String join(String[] array)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**//from w w w . ja v a2s . c om * Joins the the list elements to a string * delimited by '\t' * @param collection * @return string joined array */ public static String join(Collection<?> collection) { return join(collection, '\t'); } /** * Joins the the array elements to a string * delimited by '\t' * @param array * @return string joined array */ public static String join(String[] array) { return join(array, '\t'); } /** * Joins the the collection elements to a string * delimited by the submitted delimiter * @param collection * @param delimiter * @return string joined array */ public static String join(Collection<?> collection, Character delimiter) { if (collection == null || collection.size() == 0) return null; StringBuilder sb = new StringBuilder(); Iterator<?> it = collection.iterator(); sb.append(it.next()); while (it.hasNext()) { sb.append(delimiter); sb.append(it.next()); } return sb.toString(); } /** * Joins the the collection elements to a string * delimited by the submitted delimiter * @param collection * @param delimiter * @return string joined array */ public static String join(Collection<?> collection, String delimiter) { if (collection == null || collection.size() == 0) return null; StringBuilder sb = new StringBuilder(); Iterator<?> it = collection.iterator(); sb.append(it.next()); while (it.hasNext()) { sb.append(delimiter); sb.append(it.next()); } return sb.toString(); } /** * Joins the the array elements to a string * delimited by the submitted delimiter * @param array * @param delimiter * @return string joined array */ public static String join(String[] array, Character delimiter) { if (array == null) return null; int length = array.length; if (length == 0) return null; StringBuilder sb = new StringBuilder(); sb.append(array[0]); for (int i = 1; i < length; i++) { sb.append(delimiter); sb.append(array[i]); } return sb.toString(); } /** * Joins the the array elements to a string * delimited by the submitted delimiter * @param array * @param delimiter * @return string joined array */ public static String join(String[] array, String delimiter) { if (array == null) return null; int length = array.length; if (length == 0) return null; StringBuilder sb = new StringBuilder(); sb.append(array[0]); for (int i = 1; i < length; i++) { sb.append(delimiter); sb.append(array[i]); } return sb.toString(); } }