Class StringUtils

java.lang.Object
org.apache.tika.utils.StringUtils

public class StringUtils extends Object
  • Field Details

  • Constructor Details

    • StringUtils

      public StringUtils()
  • Method Details

    • isEmpty

      public static boolean isEmpty(CharSequence cs)
    • isBlank

      public static boolean isBlank(String s)
    • leftPad

      public static String leftPad(String str, int size, String padStr)

      Left pad a String with a specified String.

      Pad to a size of size.

       StringUtils.leftPad(null, *, *)      = null
       StringUtils.leftPad("", 3, "z")      = "zzz"
       StringUtils.leftPad("bat", 3, "yz")  = "bat"
       StringUtils.leftPad("bat", 5, "yz")  = "yzbat"
       StringUtils.leftPad("bat", 8, "yz")  = "yzyzybat"
       StringUtils.leftPad("bat", 1, "yz")  = "bat"
       StringUtils.leftPad("bat", -1, "yz") = "bat"
       StringUtils.leftPad("bat", 5, null)  = "  bat"
       StringUtils.leftPad("bat", 5, "")    = "  bat"
       
      Parameters:
      str - the String to pad out, may be null
      size - the size to pad to
      padStr - the String to pad with, null or empty treated as single space
      Returns:
      left padded String or original String if no padding is necessary, null if null String input
    • leftPad

      public static String leftPad(String str, int size, char padChar)
    • repeat

      public static String repeat(char ch, int repeat)

      Returns padding using the specified delimiter repeated to a given length.

       StringUtils.repeat('e', 0)  = ""
       StringUtils.repeat('e', 3)  = "eee"
       StringUtils.repeat('e', -2) = ""
       

      Note: this method does not support padding with Unicode Supplementary Characters as they require a pair of chars to be represented. If you are needing to support full I18N of your applications consider using repeat(String, int) instead.

      Parameters:
      ch - character to repeat
      repeat - number of times to repeat char, negative treated as zero
      Returns:
      String with repeated character
      See Also:
    • repeat

      public static String repeat(String str, int repeat)

      Repeat a String repeat times to form a new String.

       StringUtils.repeat(null, 2) = null
       StringUtils.repeat("", 0)   = ""
       StringUtils.repeat("", 2)   = ""
       StringUtils.repeat("a", 3)  = "aaa"
       StringUtils.repeat("ab", 2) = "abab"
       StringUtils.repeat("a", -2) = ""
       
      Parameters:
      str - the String to repeat, may be null
      repeat - number of times to repeat str, negative treated as zero
      Returns:
      a new String consisting of the original String repeated, null if null String input
    • joinWith

      public static String joinWith(String delimiter, List<String> lines)