diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/FileUtilities.java b/common/source/java/ch/systemsx/cisd/common/utilities/FileUtilities.java index d40fed2c568945658db3e97e32e09e92213bd15e..273d255a884fc41c2cbeb3cbc22ce04509a11e60 100644 --- a/common/source/java/ch/systemsx/cisd/common/utilities/FileUtilities.java +++ b/common/source/java/ch/systemsx/cisd/common/utilities/FileUtilities.java @@ -38,10 +38,15 @@ import ch.systemsx.cisd.common.logging.LogFactory; * * @author Bernd Rinn */ -public class FileUtilities +public final class FileUtilities { private static final Logger machineLog = LogFactory.getLogger(LogCategory.MACHINE, FileUtilities.class); - + + private FileUtilities() + { + // Can not be instantiated. + } + /** * Loads the specified text file. * diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/StringUtilities.java b/common/source/java/ch/systemsx/cisd/common/utilities/StringUtilities.java index 637bef4a8cc2492083a33e4904ed6aa3f0172d19..92cdc20e0bea394c9b57f95cfb14ac4f8d3e6a8d 100644 --- a/common/source/java/ch/systemsx/cisd/common/utilities/StringUtilities.java +++ b/common/source/java/ch/systemsx/cisd/common/utilities/StringUtilities.java @@ -18,14 +18,21 @@ package ch.systemsx.cisd.common.utilities; import java.util.List; +import org.apache.commons.lang.StringUtils; + /** * Some useful utlities methods for {@link String}s. * * @author Bernd Rinn */ -public class StringUtilities +public final class StringUtilities { + private StringUtilities() + { + // This class can not be instantiated. + } + /** * Returns the capitalized form of <var>string</var> */ @@ -45,29 +52,15 @@ public class StringUtilities */ public static String concatenateWithSpace(List<String> list) { - return concatenate(list, " "); + return StringUtils.join(list, " "); } - + /** * @return The concatenated entries of the <var>list</var>, delimited by a new line. */ public static String concatenateWithNewLine(List<String> list) { - return concatenate(list, OSUtilities.LINE_SEPARATOR); - } - - /** - * @return The concatenated entries of the <var>list</var>, delimited by <var>delimiter</var>. - */ - public static String concatenate(List<String> list, String delimiter) - { - final StringBuilder builder = new StringBuilder(); - for (String entry : list) - { - builder.append(entry).append(delimiter); - } - builder.setLength(Math.max(0, builder.length() - delimiter.length())); // Remove trailing delimiter. - return builder.toString(); + return StringUtils.join(list, OSUtilities.LINE_SEPARATOR); } }