public final class StringUtils extends Object
Strings.| Constructor and Description |
|---|
StringUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendEscaped(StringBuffer b,
String s,
char character) |
static void |
appendEscaped(StringBuffer b,
String s,
char character,
char escapeChar)
Append a String to a StringBuffer, and escaping any occurances
of the char in the String.
|
static void |
appendQuoted(StringBuffer b,
String s,
char q)
Append a String to a StringBuffer, first quoting it with a quote
character and escaping any occurrences of the quote char in the String.
|
static String |
capitalised(String name)
Capitalise the first character of the input string.
|
static String |
concatenated(String sep,
String[] xs)
Concatenate an array of Strings with a separator.
|
static byte |
hexDecoding(char c)
Decode a hex char to a byte.
|
static byte[] |
hexDecoding(String digits)
Decode a hex String into a byte Array.
|
static String |
hexEncoding(byte[] bytes)
Hex encode an Array of bytes.
|
static boolean |
isQuoted(String in)
Determine whether a String is quoted, with either quoting character.
|
static String |
nulled(String s)
Turn an empty String into a null.
|
static String |
quoted(String i,
char q)
Surround a string in quotes.
|
static String |
randomString(int length)
Generate a random String.
|
static String[] |
split(String s,
char c)
As Perl, create an Array from a String by using a
character as the Array delimiter.
|
static String |
tr(String s,
char from,
char to)
Deprecated.
now use string.replace(old,new)
|
static String |
tr(String s,
String from,
String to)
As Perl
tr; swap any occurrences of any characters in the
from string in the input string with the
corresponding character from the to string. |
static String |
uncapitalised(String name)
Uncaptialise the first character of the input string.
|
static String |
unNulled(String in)
Turn a null into an empty String.
|
public static String[] split(String s, char c)
s - the String to splitc - the Array delimiterpublic static void appendEscaped(StringBuffer b, String s, char character)
b - the buffer to append tos - the String to appendcharacter - the character to escapepublic static void appendEscaped(StringBuffer b, String s, char character, char escapeChar)
b - the buffer to append tos - the String to appendcharacter - the character to escapeescapeChar - the character to escape withpublic static void appendQuoted(StringBuffer b, String s, char q)
b - the buffer to append tos - the String to appendq - the quote characterpublic static String quoted(String i, char q)
i - the string to quoteq - The quote character to usepublic static String capitalised(String name)
name - String to capitalisepublic static String uncapitalised(String name)
name - String to uncapitalisepublic static String tr(String s, String from, String to)
tr; swap any occurrences of any characters in the
from string in the input string with the
corresponding character from the to string.
tr("melati", "ait", "osn").equals("melons")
s - String to act uponfrom - String containing characters to swap fromto - String containing characters to swap topublic static String tr(String s, char from, char to)
tr; swap any occurances of the
from character in the input string with the
corresponding the to character.
tr("melati", 'i', 'o').equals("melato")
s - String to act uponfrom - character to swap fromto - character to swap topublic static String concatenated(String sep, String[] xs)
sep - The separator String to use, may be null.xs - An array of Strings to concatenate.public static String randomString(int length)
length - the required length of the String returnedpublic static String nulled(String s)
s - input String, possibly of zero length or nullpublic static String unNulled(String in)
in - input String, possibly nullpublic static String hexEncoding(byte[] bytes)
bytes - the byte Arraypublic static byte hexDecoding(char c)
c - the charpublic static byte[] hexDecoding(String digits)
digits - the hex Stringpublic static boolean isQuoted(String in)
in - String to examineCopyright © 2000–2021 PanEris. All rights reserved.