edu.umd.cs.findbugs.util

Class Strings

public class Strings extends Object

A class for static String utility methods.

Author: Brian Cole

Method Summary
static Stringreplace(String source, String find, String repl)
This is intended to be semantically equivalent to source.replace(find, repl) but also compatible with JDK 1.4.
static StringtoString(Object[] a)
This is intended to be equivalent to Arrays.toString(a) but also compatible with JDK 1.4.
static StringtrimComma(String s)
Trim trailing comma from given string.

Method Detail

replace

public static String replace(String source, String find, String repl)
This is intended to be semantically equivalent to source.replace(find, repl) but also compatible with JDK 1.4.

Parameters: source The String on which to operate find The literal substring to be replaced repl The literal replacement substring

Returns: The resultant String after substitution

Throws: NullPointerException if any of the arguments are null IllegalArgumentException if find has zero length

See Also: java.lang.String#replace(CharSequence target, CharSequence replacement)

toString

public static String toString(Object[] a)
This is intended to be equivalent to Arrays.toString(a) but also compatible with JDK 1.4. This concatenates the results of calling String.valueOf() on each element of the array, so this won't work well for multi-dimensional arrays.

See Also: java.lang.String#valueOf(Object) java.util.Arrays#toString(Object[]) java.util.Arrays#deepToString(Object[])

trimComma

public static String trimComma(String s)
Trim trailing comma from given string.

Parameters: s a string

Returns: the same string with trailing comma trimmed (if any)

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.