public class StringUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
EOL |
static String |
NEWLINE |
| Modifier and Type | Method and Description |
|---|---|
static String |
cat(String separator,
String... list)
Concatenate a list of strings, putting a separator in between each one.
|
static String |
escapeForHtml(String str)
Escape characters to use result in html.
|
static String |
formatSQLException(SQLException ex) |
static String |
getPenultimateDirName(String s) |
static String |
getProperty(String propName)
Get a system propety given a property name, possibly trying all combination
of upercase, name mangling to get a value.
|
static String |
getStackTrace(Throwable t) |
static boolean |
isHex(char c) |
static boolean |
isHex(String s) |
static boolean |
isToken(String s) |
static void |
main(String[] args) |
static String |
makeFilePath(String[] strings,
boolean addTrailing)
A utility to get the Operating System specific path from given array
of Strings.
|
static int |
maxWidth(Vector v) |
static String |
nvl(String str)
If given
String is null then returns empty String
otherwise returns given String |
static boolean |
ok(String s) |
static String |
padLeft(String s,
int len) |
static String |
padRight(String s,
int len) |
static List<String> |
parseStringList(String line)
Parses a string containing substrings separated from
each other by the standard separator characters and returns
a list of strings.
|
static List<String> |
parseStringList(String line,
String sep)
Parses a string containing substrings separated from
each other by the specified set of separator characters and returns
a list of strings.
|
static void |
prepend(String[] ss,
String what) |
static String |
quotePathIfNecessary(String path)
Nightmares can result from using a path with a space in it!
This method will enclose in double-quotes if needed.
|
static String |
quotePathIfNecessary(String path,
char quoteChar)
Nightmares can result from using a path with a space in it!
This method will enclose in the specified quote characters if needed.
|
static String |
removeChar(String strOrig,
char c)
Remove a character from a String
|
static String |
removeEnclosingQuotes(String s)
Removes the quoting around a String.
|
static String |
replace(String s,
String token,
String replace) |
static int |
safeLength(String s)
return the length of the String - or 0 if it's null
|
static String |
stripToken(String s) |
static void |
testUpperCase() |
static String[] |
toLines(String s) |
static String |
toShortClassName(String className) |
static String |
toString(Properties props) |
static String |
upperCaseFirstLetter(String s) |
public static int safeLength(String s)
public static boolean ok(String s)
public static String formatSQLException(SQLException ex)
public static int maxWidth(Vector v)
public static boolean isHex(String s)
public static boolean isHex(char c)
public static String toString(Properties props)
public static void main(String[] args)
public static void testUpperCase()
public static String makeFilePath(String[] strings, boolean addTrailing)
strings - an array of Strings participating in the path.addTrailing - a boolean that determines whether the returned
String should have a trailing File Separator character. None of
the strings may be null or empty String. An exception is thrown.IllegalArgumentException - if any of the arguments is null or is
an empty string.public static List<String> parseStringList(String line)
line into individual string elements
separated by the field separators, and returns these individual
strings as a list of strings. The individual string elements are
trimmed of leading and trailing whitespace. Only non-empty strings
are returned in the list.line - The string to splitpublic static List<String> parseStringList(String line, String sep)
line into individual string elements
separated by the field separators specified in sep,
and returns these individual strings as a list of strings. The
individual string elements are trimmed of leading and trailing
whitespace. Only non-empty strings are returned in the list.line - The string to splitsep - The list of separators to use for determining where the
string should be split. If null, then the standard
separators (see StringTokenizer javadocs) are used.public static String getProperty(String propName)
propName - the approximate system property namepublic static String removeChar(String strOrig, char c)
strOrig - original stringc - character to remove from the stringpublic static final boolean isToken(String s)
public static String cat(String separator, String... list)
separator - Separator to use between concatenated stringslist - List of strings to concatenate togetherpublic static String removeEnclosingQuotes(String s)
s - The String that may have enclosing quotespublic static String quotePathIfNecessary(String path)
path - public static String quotePathIfNecessary(String path, char quoteChar)
path - public static String escapeForHtml(String str)
| Chars | Escape sequence |
|---|---|
| < | < |
| > | > |
| & | & |
| " | " |
| \t |
Copyright © 2017–2020 Eclipse Foundation. All rights reserved.