@Internal public class StringUtils extends java.lang.Object
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
byteArrayToJsonString(byte[] bytes)
Converts the given array of bytes into a legal JSON string.
|
static int |
getLevenshteinDistance(java.lang.String s,
java.lang.String t)
Calculate the Levenshtein distance between two strings.
|
static byte[] |
jsonStringToByteArray(java.lang.String string)
Converts the given string, encoded using
byteArrayToJsonString(byte[]) , into a byte array. |
public static java.lang.String byteArrayToJsonString(byte[] bytes)
Uses a simple strategy of converting each byte to a single char, except for non-printable chars, non-ASCII chars, and '%', '\', and '"', which are encoded as three chars in '%xx' format, where 'xx' is the hexadecimal encoding of the byte.
public static byte[] jsonStringToByteArray(java.lang.String string)
byteArrayToJsonString(byte[])
, into a byte array.java.lang.IllegalArgumentException
- if the argument string is not legalpublic static int getLevenshteinDistance(java.lang.String s, java.lang.String t)
The Levenshtein distance between two words is the minimum number of single-character edits (i.e. insertions, deletions or substitutions) required to change one string into the other.