public final class StringUtil extends Object
| Modifier and Type | Field and Description | 
|---|---|
static String | 
LINE_SEPARATOR
Points to the System property 'line.separator'. 
 | 
static Locale | 
LOCALE_INTERNAL
LOCALE_INTERNAL is the default locale for string operations and number formatting. 
 | 
static Charset | 
UTF8_CHARSET
UTF-8 Charset 
 | 
static Pattern | 
VERSION_PATTERN
Pattern used to tokenize version strings. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
static String | 
bytesToString(byte[] bytes)
Creates a UTF8_CHARSET string from a byte array. 
 | 
static String | 
bytesToString(byte[] bytes,
             int offset,
             int length)
Creates a UTF8_CHARSET string from a byte array. 
 | 
static boolean | 
equalsIgnoreCase(String str1,
                String str2)
Returns true if two strings are equals ignoring the letter case in  
LOCALE_INTERNAL locale. | 
static String | 
getterIntoProperty(String getterName)
Convert getter into a property name
 Example: 'getFoo' is converted into 'foo'
 It's written defensively, when output is not a getter then it
 returns the original name. 
 | 
static int | 
indexOf(String input,
       char ch)
Like a String.indexOf but without MIN_SUPPLEMENTARY_CODE_POINT handling 
 | 
static int | 
indexOf(String input,
       char ch,
       int offset)
Like a String.indexOf but without MIN_SUPPLEMENTARY_CODE_POINT handling 
 | 
static String[] | 
intersection(String[] arr1,
            String[] arr2)
Returns intersection of given String arrays. 
 | 
static boolean | 
isNullOrEmpty(String s)
Checks if a string is empty or not. 
 | 
static boolean | 
isNullOrEmptyAfterTrim(String s)
Checks if a string is empty or not after trim operation 
 | 
static int | 
lastIndexOf(String input,
           char ch)
Like a String.lastIndexOf but without MIN_SUPPLEMENTARY_CODE_POINT handling 
 | 
static int | 
lastIndexOf(String input,
           char ch,
           int offset)
Like a String.lastIndexOf but without MIN_SUPPLEMENTARY_CODE_POINT handling 
 | 
static String | 
lowerCaseInternal(String s)
HC specific settings, operands etc. 
 | 
static String[] | 
splitByComma(String input,
            boolean allowEmpty)
Splits String value with comma "," used as a separator. 
 | 
static byte[] | 
stringToBytes(String s)
Creates a byte array from a string. 
 | 
static String[] | 
subraction(String[] arr1,
          String[] arr2)
Returns subtraction between given String arrays. 
 | 
static String | 
timeToString(long timeMillis)
Returns a String representation of the time. 
 | 
static String | 
timeToStringFriendly(long timeMillis)
Returns a String representation of the time. 
 | 
static String[] | 
tokenizeVersionString(String version)
Tokenizes a version string and returns the tokens with the following grouping:
 (1) major version, eg "3"
 (2) minor version, eg "8"
 (3) patch version prefixed with ".", if exists, otherwise  
null (eg ".0")
 (4) patch version, eg "0"
 (5) 1st -qualifier, if exists
 (6) -SNAPSHOT qualifier, if exists | 
static String | 
trim(String input)
Trim whitespaces. 
 | 
static String | 
upperCaseInternal(String s)
HC specific settings, operands etc. 
 | 
public static final Charset UTF8_CHARSET
public static final String LINE_SEPARATOR
public static final Locale LOCALE_INTERNAL
java.util.Locale.US (US English).public static final Pattern VERSION_PATTERN
public static String bytesToString(byte[] bytes, int offset, int length)
bytes - the byte array.offset - the index of the first byte to decodelength - the number of bytes to decodepublic static String bytesToString(byte[] bytes)
bytes - the byte array.public static byte[] stringToBytes(String s)
s - the string.public static boolean isNullOrEmpty(String s)
s - the string to check.null or empty, false otherwisepublic static boolean isNullOrEmptyAfterTrim(String s)
s - the string to check.null or empty, false otherwisepublic static String upperCaseInternal(String s)
s - the given stringnull/empty if the string is null/emptypublic static String lowerCaseInternal(String s)
s - the given stringnull/empty if the string is null/emptypublic static String timeToString(long timeMillis)
This method is not particularly efficient since it generates a ton of litter.
timeMillis - time in millispublic static String timeToStringFriendly(long timeMillis)
This method is not particularly efficient since it generates a ton of litter.
timeMillis - time in millispublic static int indexOf(String input, char ch, int offset)
input - to check the indexOf onch - character to find the index ofoffset - offset to start the reading frompublic static int indexOf(String input, char ch)
input - to check the indexOf onch - character to find the index ofpublic static int lastIndexOf(String input, char ch, int offset)
input - to check the indexOf onch - character to find the index ofoffset - offset to start the reading from the endpublic static int lastIndexOf(String input, char ch)
input - to check the indexOf onch - character to find the index ofpublic static String[] tokenizeVersionString(String version)
null (eg ".0")
 (4) patch version, eg "0"
 (5) 1st -qualifier, if exists
 (6) -SNAPSHOT qualifier, if existsversion - public static String getterIntoProperty(String getterName)
getterName - public static String trim(String input)
String.trim()) doesn't limit to space character.input - string to trimnull if provided value was null, input with removed leading and trailing whitespacespublic static String[] splitByComma(String input, boolean allowEmpty)
input - string to splitnull if provided value was null, split parts otherwise (trimmed)public static String[] intersection(String[] arr1, String[] arr2)
null, then null is returned.arr1 - first arrayarr2 - second arraypublic static String[] subraction(String[] arr1, String[] arr2)
arr1 - first arrayarr2 - second arraypublic static boolean equalsIgnoreCase(String str1, String str2)
LOCALE_INTERNAL locale.str1 - first string to comparestr2 - second string to compareCopyright © 2020 Hazelcast, Inc.. All Rights Reserved.