Class StringUtils


  • public class StringUtils
    extends Object
    Version:
    July 18, 2017
    Author:
    Javier Rojas Blum
    • Method Detail

      • nullToEmpty

        public static String nullToEmpty​(String str)
      • equals

        @Deprecated
        public static boolean equals​(String str1,
                                     String str2)
        Deprecated.
        it is possible to use directly: org.apache.commons.lang.StringUtils.equals(str1, str2);
        Check if first and second String Params are equals, even if both are null.
        Parameters:
        str1 - first String param
        str2 - second String param
        Returns:
        true if both are null, true if both are equals, false in other cases
      • equalsIgnoringSpaces

        public static boolean equalsIgnoringSpaces​(String a,
                                                   String b)
      • implode

        public static String implode​(String[] inputArray,
                                     String glueString)
        Method to join array elements of type string
        Parameters:
        inputArray - Array which contains strings
        glueString - String between each array element
        Returns:
        String containing all array elements separated by glue string.
      • implode

        public static String implode​(Collection<? extends Object> collection,
                                     String glueString)
        Method to join a list of elements of type string
        Parameters:
        collection - List which contains strings
        glueString - String between each array element
        Returns:
        String containing all array elements separated by glue string.
      • spaceSeparatedToList

        public static List<String> spaceSeparatedToList​(String spaceSeparatedString)
      • toJSONArray

        public static org.json.JSONArray toJSONArray​(List<? extends Object> inputList)
      • toList

        public static List<String> toList​(org.json.JSONArray jsonArray)
                                   throws org.json.JSONException
        Throws:
        org.json.JSONException
      • parseSilently

        public static Date parseSilently​(String string)
      • generateRandomReadableCode

        public static String generateRandomReadableCode​(byte length)
        Generates a code using a base of 20 characters easy to read for users, using parametrized length separated by dashes with intervals of 4 characters.
      • generateRandomCode

        public static String generateRandomCode​(byte seedLength)
        Generates a random code using a byte array as its seed.
        Parameters:
        seedLength - Length of the byte array
      • base64urlencode

        public static String base64urlencode​(String string)