public class StrRepeater extends Object
Constructor and Description |
---|
StrRepeater(int countOrLength)
构造
|
Modifier and Type | Method and Description |
---|---|
static StrRepeater |
of(int countOrLength)
创建StrRepeater
|
String |
repeat(char c)
重复某个字符
repeat('e', 0) = ""
repeat('e', 3) = "eee"
repeat('e', -2) = ""
|
String |
repeat(CharSequence str)
重复某个字符串
|
String |
repeatAndJoin(CharSequence str,
CharSequence delimiter)
重复某个字符串并通过分界符连接
repeatAndJoin("?"
|
String |
repeatByLength(CharSequence str)
重复某个字符串到指定长度
如果指定长度非指定字符串的整数倍,截断到固定长度
如果指定长度小于字符串本身的长度,截断之
|
public StrRepeater(int countOrLength)
countOrLength
- 重复次数或固定长度public static StrRepeater of(int countOrLength)
countOrLength
- 重复次数或固定长度public String repeat(char c)
repeat('e', 0) = "" repeat('e', 3) = "eee" repeat('e', -2) = ""
c
- 被重复的字符public String repeat(CharSequence str)
str
- 被重复的字符public String repeatByLength(CharSequence str)
str
- 被重复的字符public String repeatAndJoin(CharSequence str, CharSequence delimiter)
repeatAndJoin("?", 5, ",") = "?,?,?,?,?" repeatAndJoin("?", 0, ",") = "" repeatAndJoin("?", 5, null) = "?????"
str
- 被重复的字符串delimiter
- 分界符Copyright © 2025. All rights reserved.