Package de.tilman_neumann.util
Class StringUtil
- java.lang.Object
-
- de.tilman_neumann.util.StringUtil
-
public class StringUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
formatLeft(String s, String mask)
Inserts a string s left-aligned into a mask, without truncation.
Examples:
formatLeft("abc", "123456") -> "abc456"
formatLeft("abcdef", "123") -> "abcdef"static String
formatRight(String s, String mask)
Inserts a string s right-aligned into a mask, without truncation.
Examples:
formatRight("abc", "123456") -> "123abc"
formatRight("abcdef", "123") -> "abcdef"static String
repeat(String s, int n)
Concatenates string s n times.
-
-
-
Method Detail
-
repeat
public static String repeat(String s, int n)
Concatenates string s n times.- Parameters:
s
- string to repeatn
- number of repetitions- Returns:
- a string resulting from n repetitions of s, or null if n <= 0
-
formatLeft
public static String formatLeft(String s, String mask)
Inserts a string s left-aligned into a mask, without truncation.
Examples:
formatLeft("abc", "123456") -> "abc456"
formatLeft("abcdef", "123") -> "abcdef"- Parameters:
s
-mask
-- Returns:
- s left-aligned in mask
-
-