Class StringUtils
-
- All Implemented Interfaces:
@Deprecated() public final class StringUtils
Implements utility functions to facilitate work with Strings.
Grigorii Balutsel
Emil Ivov
-
-
Method Summary
Modifier and Type Method Description static booleanisNullOrEmpty(String s)Checks whether a string is nullor blank (empty or whitespace).static booleanisNullOrEmpty(String s, boolean trim)Indicates whether string is null or empty. static InputStreamfromString(String string)Creates InputStream from the string in UTF8 encoding. static InputStreamfromString(String string, String encoding)Creates InputStream from the string in the specified encoding. static Array<byte>getUTF8Bytes(String string)Returns the UTF8 bytes for string and handles the unlikely case where UTF-8 is not supported. static StringgetUTF8String(Array<byte> bytes)Converts string into an UTF8 String and handles the unlikely case where UTF-8 is not supported. static booleancontainsLetters(String string)Indicates whether the given string contains any letters. static StringnewString(Array<byte> bytes)Initializes a new String instance by decoding a specified array of bytes (mostly used by JNI). -
-
Method Detail
-
isNullOrEmpty
static boolean isNullOrEmpty(String s)
Checks whether a string is
nullor blank (empty or whitespace).- Parameters:
s- the string to analyze.- Returns:
trueif the string isnullor blank.
-
isNullOrEmpty
static boolean isNullOrEmpty(String s, boolean trim)
Indicates whether string is null or empty.
- Parameters:
s- the string to analyze.trim- indicates whether to trim the string.- Returns:
true if string is null or empty.
-
fromString
static InputStream fromString(String string)
Creates InputStream from the string in UTF8 encoding.
- Parameters:
string- the string to convert.- Returns:
the InputStream.
-
fromString
static InputStream fromString(String string, String encoding)
Creates InputStream from the string in the specified encoding.
- Parameters:
string- the string to convert.encoding- the encoding- Returns:
the InputStream.
-
getUTF8Bytes
static Array<byte> getUTF8Bytes(String string)
Returns the UTF8 bytes for string and handles the unlikely case where UTF-8 is not supported.
- Parameters:
string- the String whose bytes we'd like to obtain.- Returns:
string's bytes.
-
getUTF8String
static String getUTF8String(Array<byte> bytes)
Converts string into an UTF8 String and handles the unlikely case where UTF-8 is not supported.
- Parameters:
bytes- the byte array that we'd like to convert into a String.- Returns:
the UTF-8 String.
-
containsLetters
static boolean containsLetters(String string)
Indicates whether the given string contains any letters.
- Parameters:
string- the string to check for letters- Returns:
true if the given string contains letters; false, otherwise
-
newString
static String newString(Array<byte> bytes)
Initializes a new String instance by decoding a specified array of bytes (mostly used by JNI).
- Parameters:
bytes- the bytes to be decoded into characters/a new String instance- Returns:
a new String instance whose characters were decoded from the specified bytes
-
-
-
-