Class TextUtil

java.lang.Object
de.eldoria.eldoutilities.utils.TextUtil

public final class TextUtil extends Object
Basic text utilities
Since:
1.0.0
  • Method Details

    • countChars

      public static int countChars(String string, char count)
      Count how often the char was used inside the string.
      Parameters:
      string - string to check
      count - char to count
      Returns:
      the number of occurences of the char in the string.
    • cropText

      public static String cropText(String string, String endSequence, int maxChars, boolean keepWords)
      Trims a text to the desired length. Returns unmodified input if max chars is larger or equal string.length().
      Parameters:
      string - String to trim
      endSequence - end sequence which should be append at the end of the string. included in max chars.
      maxChars - max char length.
      keepWords - true if no word should be cut.
      Returns:
      String with length of maxChars of shorter.