public class StringUtil extends Object
Constructor and Description |
---|
StringUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
capitalize(String s)
Capitalizes the given string.
|
static boolean |
contains(String string,
String substring)
Returns true if substring is indeed a substring of string.
|
static boolean |
containsIgnoreCase(String string,
String substring)
Returns true if substring is indeed a substring of string.
|
static String |
currentMethodName() |
static String |
escapeHTML(String s) |
static String |
format(double d,
int decimals)
Returns d as a string truncated to the specified number of decimal places
|
static List |
fromCommaDelimitedString(String s)
Converts the comma-delimited string into a List of trimmed strings.
|
static String |
getStackTrace(Throwable t)
Returns an throwable's stack trace
|
static String |
getStackTrace(Throwable t,
int depth) |
static String |
getTimeString(long milliseconds)
Converts the milliseconds value into a String of the form "9d 22h 15m 8s".
|
static String |
indent(String original,
int spaces) |
static int |
indexOfIgnoreParentheses(char c,
String s,
int start)
Returns the position of the first occurrence of the given character found
in s starting at start.
|
static boolean |
isInteger(String s)
Returns true if s can be converted to an int.
|
static String |
leftPad(String original,
int length,
char padChar)
Pads the String with the given character until it has the given length.
|
static String |
removeConsecutiveDuplicates(String s)
Replaces consecutive instances of characters with single instances.
|
static String |
removeFromEnd(String s,
String strToRemove) |
static String |
removeVowels(String s)
Removes vowels from the string.
|
static String |
removeVowelsSkipStarts(String s)
Removes vowels from the string except those that start words.
|
static void |
replace(StringBuffer orig,
String o,
String n,
boolean all)
Replaces all instances of the String o with the String n in the
StringBuffer orig if all is true, or only the first instance if all is
false.
|
static String |
replace(String str,
char oldChar,
String newStr)
Returns a string with all occurrences of oldChar replaced by newStr
|
static String |
replace(String original,
String oldSubstring,
String newSubstring,
boolean all)
Returns original with occurrences of oldSubstring replaced by
newSubstring.
|
static String |
replaceAll(String original,
String oldSubstring,
String newSubstring)
Returns original with all occurrences of oldSubstring replaced by
newSubstring
|
static String |
replaceFirst(String original,
String oldSubstring,
String newSubstring)
Returns original with the first occurrenc of oldSubstring replaced by
newSubstring
|
static String |
rightPad(String original,
int length,
char padChar)
Pads the String with the given character until it has the given length.
|
static String |
stringOfChar(char ch,
int count)
Returns a String of the given length consisting entirely of the given
character
|
static String |
stripHTMLTags(String original)
Removes the HTML tags from the given String, inserting line breaks at
appropriate places.
|
static String |
toCommaDelimitedString(Collection c)
Returns the elements of c separated by commas.
|
static String |
toCommaDelimitedStringInQuotes(Collection c)
Returns the elements of c separated by commas and enclosed in
single-quotes
|
static Vector |
toLowerCase(List v)
Returns the elements of v in lowercase
|
static String |
toStringNeverNull(Object o)
If s is null, returns "null"; otherwise, returns s.
|
static Vector |
toUpperCase(Vector v)
Returns the elements of v in uppercase
|
static String |
wrap(String s,
int n)
Line-wraps a string s by inserting CR-LF instead of the first space after the nth
columns.
|
public static final String newLine
public static String capitalize(String s)
s
- the string to capitalizepublic static boolean isInteger(String s)
public static String getTimeString(long milliseconds)
public static boolean containsIgnoreCase(String string, String substring)
public static boolean contains(String string, String substring)
public static String replace(String str, char oldChar, String newStr)
public static String stringOfChar(char ch, int count)
public static String toCommaDelimitedStringInQuotes(Collection c)
public static String toCommaDelimitedString(Collection c)
public static List fromCommaDelimitedString(String s)
public static String toStringNeverNull(Object o)
public static void replace(StringBuffer orig, String o, String n, boolean all)
public static String replaceAll(String original, String oldSubstring, String newSubstring)
public static String replaceFirst(String original, String oldSubstring, String newSubstring)
public static String leftPad(String original, int length, char padChar)
public static String rightPad(String original, int length, char padChar)
public static String stripHTMLTags(String original)
public static String format(double d, int decimals)
public static String wrap(String s, int n)
public static String removeVowels(String s)
public static String removeVowelsSkipStarts(String s)
public static String removeConsecutiveDuplicates(String s)
public static int indexOfIgnoreParentheses(char c, String s, int start)
public static String replace(String original, String oldSubstring, String newSubstring, boolean all)
public static String currentMethodName()
Copyright © 2017. All rights reserved.