Here you can find the source of arrayToStringDelimited(final String[] array, final String delimiter)
Parameter | Description |
---|---|
array | the array |
delimiter | the delimiter |
public static String arrayToStringDelimited(final String[] array, final String delimiter)
//package com.java2s; /*/* w w w.j a v a 2 s . co m*/ * DeviceUtil.java * Copyright (c) 2013, EcoFactor, All Rights Reserved. * * This software is the confidential and proprietary information of EcoFactor * ("Confidential Information"). You shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement you entered into with * EcoFactor. */ public class Main { /** * Array to string delimited. This method will convert a String array into a String delimited by * <strong>delimiter</strong>. </br>If the String array is NULL or EMPTY, the method returns an * empty string. * @param array the array * @param delimiter the delimiter * @return the string */ public static String arrayToStringDelimited(final String[] array, final String delimiter) { final StringBuilder buffer = new StringBuilder(); final int arrayLength = array != null ? array.length : 0; for (int i = 0; i < arrayLength - 1; i++) { buffer.append(array[i]).append(delimiter); } buffer.append(arrayLength > 0 ? array[arrayLength - 1] : ""); return buffer.toString(); } }