public final class StringUtilities extends Object
Modifier and Type | Field and Description |
---|---|
static String |
FOLDER_SEPARATOR |
Modifier and Type | Method and Description |
---|---|
static int |
count(String s,
char c) |
static String |
createString(byte[] bytes,
String encoding)
Convert a byte[] into a String with a particular encoding.
|
static String |
createUtf8String(byte[] bytes)
Convert a byte[] into a UTF-8 String.
|
static String |
createUTF8String(byte[] bytes)
Convert a byte[] into a UTF-8 encoded String.
|
static int |
damerauLevenshteinDistance(CharSequence source,
CharSequence target)
Calculate the Damerau-Levenshtein Distance between two strings.
|
static byte[] |
decode(String s) |
static String |
encode(byte[] bytes)
Convert a byte array into a printable format containing a
String of hex digit characters (two per byte).
|
static boolean |
equals(String str1,
String str2) |
static boolean |
equalsIgnoreCase(String s1,
String s2) |
static boolean |
equalsIgnoreCaseWithTrim(String s1,
String s2) |
static boolean |
equalsWithTrim(String s1,
String s2) |
static byte[] |
getBytes(String s,
String encoding)
Convert a String into a byte[] with a particular encoding.
|
static String |
getRandomChar(Random random,
boolean upper) |
static String |
getRandomString(Random random,
int minLen,
int maxLen) |
static byte[] |
getUTF8Bytes(String s)
Convert a String into a byte[] encoded by UTF-8.
|
static boolean |
hasContent(String s) |
static boolean |
isEmpty(String s) |
static int |
lastIndexOf(String path,
char ch) |
static int |
length(String s)
Use this method when you don't want a length check to
throw a NullPointerException when
|
static int |
levenshteinDistance(CharSequence s,
CharSequence t)
The Levenshtein distance is a string metric for measuring the difference between two sequences.
|
static int |
trimLength(String s)
Returns the length of the trimmed string.
|
static String |
wildcardToRegexString(String wildcard)
Convert strings containing DOS-style '*' or '?' to a regex String.
|
public static final String FOLDER_SEPARATOR
public static boolean isEmpty(String s)
public static boolean hasContent(String s)
public static int length(String s)
s
- string to return length ofpublic static int trimLength(String s)
public static int lastIndexOf(String path, char ch)
public static byte[] decode(String s)
public static String encode(byte[] bytes)
bytes
- array representationpublic static int count(String s, char c)
public static String wildcardToRegexString(String wildcard)
public static int levenshteinDistance(CharSequence s, CharSequence t)
s
- String onet
- String twopublic static int damerauLevenshteinDistance(CharSequence source, CharSequence target)
source
- Source input stringtarget
- Target input stringpublic static String getRandomString(Random random, int minLen, int maxLen)
random
- Random instanceminLen
- minimum number of charactersmaxLen
- maximum number of characterspublic static byte[] getBytes(String s, String encoding)
s
- string to encode into bytesencoding
- encoding to usepublic static String createUtf8String(byte[] bytes)
bytes
- bytes to encode into a stringpublic static byte[] getUTF8Bytes(String s)
s
- string to encode into bytespublic static String createString(byte[] bytes, String encoding)
bytes
- bytes to encode into a stringencoding
- encoding to usepublic static String createUTF8String(byte[] bytes)
bytes
- bytes to encode into a stringCopyright © 2015. All rights reserved.