Class StringUtils

  • All Implemented Interfaces:

    @Deprecated() 
    public final class StringUtils
    
                        

    Implements utility functions to facilitate work with Strings.

    Author:

    Grigorii Balutsel

    Emil Ivov

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static boolean isNullOrEmpty(String s) Checks whether a string is null or blank (empty or whitespace).
      static boolean isNullOrEmpty(String s, boolean trim) Indicates whether string is null or empty.
      static InputStream fromString(String string) Creates InputStream from the string in UTF8 encoding.
      static InputStream fromString(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 String getUTF8String(Array<byte> bytes) Converts string into an UTF8 String and handles the unlikely case where UTF-8 is not supported.
      static boolean containsLetters(String string) Indicates whether the given string contains any letters.
      static String newString(Array<byte> bytes) Initializes a new String instance by decoding a specified array of bytes (mostly used by JNI).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • isNullOrEmpty

         static boolean isNullOrEmpty(String s)

        Checks whether a string is null or blank (empty or whitespace).

        Parameters:
        s - the string to analyze.
        Returns:

        true if the string is null or 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