Class StringUtil

java.lang.Object
com.liferay.petra.string.StringUtil

public class StringUtil extends Object
The String utility class.
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • equalsIgnoreCase

      public static boolean equalsIgnoreCase(char c1, char c2)
    • equalsIgnoreCase

      public static boolean equalsIgnoreCase(String s1, String s2)
      Returns true if the strings are equal, ignoring case.
      Parameters:
      s1 - the first string to compare
      s2 - the second string to compare
      Returns:
      true if the strings are equal, ignoring case; false otherwise
    • merge

      public static String merge(boolean[] array, String delimiter)
    • merge

      public static String merge(byte[] array, String delimiter)
    • merge

      public static String merge(char[] array, String delimiter)
    • merge

      public static <T> String merge(Collection<T> collection, Function<T,String> toStringFunction, String delimiter)
    • merge

      public static <T> String merge(Collection<T> collection, String delimiter)
    • merge

      public static String merge(double[] array, String delimiter)
    • merge

      public static String merge(float[] array, String delimiter)
    • merge

      public static String merge(int[] array, String delimiter)
    • merge

      public static <T, L extends List<T> & RandomAccess> String merge(L list, Function<T,String> toStringFunction, String delimiter)
    • merge

      public static <T, L extends List<T> & RandomAccess> String merge(L list, String delimiter)
    • merge

      public static String merge(long[] array, String delimiter)
    • merge

      public static String merge(short[] array, String delimiter)
    • merge

      public static String merge(String[] array, String delimiter)
    • merge

      public static <T> String merge(T[] array, Function<T,String> toStringFunction, String delimiter)
    • merge

      public static <T> String merge(T[] array, String delimiter)
    • read

      public static String read(ClassLoader classLoader, String name) throws IOException
      Throws:
      IOException
    • read

      public static String read(ClassLoader classLoader, String name, boolean all) throws IOException
      Throws:
      IOException
    • read

      public static String read(InputStream inputStream) throws IOException
      Throws:
      IOException
    • replace

      public static String replace(String s, char oldSub, char newSub)
      Replaces all occurrences of the character with the new character.
      Parameters:
      s - the original string
      oldSub - the character to be searched for and replaced in the original string
      newSub - the character with which to replace the oldSub character
      Returns:
      a string representing the original string with all occurrences of the oldSub character replaced with the newSub character, or null if the original string is null
    • replace

      public static String replace(String s, String oldSub, String newSub)
      Replaces all occurrences of the string with the new string.
      Parameters:
      s - the original string
      oldSub - the string to be searched for and replaced in the original string
      newSub - the string with which to replace the oldSub string
      Returns:
      a string representing the original string with all occurrences of the oldSub string replaced with the string newSub, or null if the original string is null
    • replace

      public static String replace(String s, String oldSub, String newSub, int fromIndex)
      Replaces all occurrences of the string with the new string, starting from the specified index.
      Parameters:
      s - the original string
      oldSub - the string to be searched for and replaced in the original string
      newSub - the string with which to replace the oldSub string
      fromIndex - the index of the original string from which to begin searching
      Returns:
      a string representing the original string with all occurrences of the oldSub string occurring after the specified index replaced with the string newSub, or null if the original string is null
    • split

      public static List<String> split(String s)
    • split

      public static List<String> split(String s, char delimiter)