All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.cern.mig.utils.StringUtils Maven / Gradle / Ivy

There is a newer version: 1.8
Show newest version
/**
 * General String useful stuff.
 */
package ch.cern.mig.utils;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

/**
 * Useful String utility.
 *
 * @author Massimo Paladin - [email protected] 
* Copyright (C) CERN 2012-2013 */ public class StringUtils { public StringUtils() { } public static String join(Object[] arguments) { return join(Arrays.asList(arguments)); } public static String join(Object[] arguments, String glue) { return join(Arrays.asList(arguments), glue); } public static String join(List arguments) { return join(arguments, ", "); } public static String join(List arguments, String glue) { if (arguments == null) { return ""; } StringBuilder output = new StringBuilder(); Iterator it = arguments.iterator(); while (it.hasNext()) { output.append(it.next().toString()); if (it.hasNext()) { output.append(glue); } } return output.toString(); } }