Package org.apache.tika.utils
Class StringUtils
- java.lang.Object
-
- org.apache.tika.utils.StringUtils
-
public class StringUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description StringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isBlank(String s)
static boolean
isEmpty(CharSequence cs)
static String
joinWith(String delimiter, List<String> lines)
static String
leftPad(String str, int size, char padChar)
static String
leftPad(String str, int size, String padStr)
Left pad a String with a specified String.static String
repeat(char ch, int repeat)
Returns padding using the specified delimiter repeated to a given length.static String
repeat(String str, int repeat)
Repeat a Stringrepeat
times to form a new String.
-
-
-
Field Detail
-
EMPTY
public static final String EMPTY
The empty String""
.- Since:
- 2.0
- See Also:
- Constant Field Values
-
SPACE
public static final String SPACE
A String for a space character.- Since:
- 3.2
- See Also:
- Constant Field Values
-
-
Method Detail
-
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 nullsize
- the size to pad topadStr
- 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
-
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
char
s to be represented. If you are needing to support full I18N of your applications consider usingrepeat(String, int)
instead.- Parameters:
ch
- character to repeatrepeat
- number of times to repeat char, negative treated as zero- Returns:
- String with repeated character
- See Also:
repeat(String, int)
-
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 nullrepeat
- 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
-
-