public class TirsciUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
private static org.slf4j.Logger |
log |
private static SecureRandom |
RANDOM |
| Modifier | Constructor and Description |
|---|---|
private |
TirsciUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
format(String strPattern,
Object... argArray)
格式化文本, {} 表示占位符
此方法只是简单将占位符 {} 按照顺序替换为参数
如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
例:
// 通常使用 -> this is a for b
format("this is {} for {}", "a", "b")
// 转义{}:-> this is \{} for a
format("this is \\{} for {}", "a", "b")
// 转义\::-> this is \a for b
format("this is \\\\{} for {}", "a", "b")
|
static int |
nextInt(int bound)
随机整数 [0,bound)
|
static <T> T |
tryCatch(SupplierException<T> supplier)
异常捕获起来
|
private static final org.slf4j.Logger log
private static final SecureRandom RANDOM
public static <T> T tryCatch(SupplierException<T> supplier)
T - 类型supplier - 要执行的方法public static String format(String strPattern, Object... argArray)
格式化文本, {} 表示占位符
此方法只是简单将占位符 {} 按照顺序替换为参数
如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
例:
// 通常使用 -> this is a for b
format("this is {} for {}", "a", "b")
// 转义{}:-> this is \{} for a
format("this is \\{} for {}", "a", "b")
// 转义\::-> this is \a for b
format("this is \\\\{} for {}", "a", "b")
strPattern - 文本模板,被替换的部分用 {} 表示argArray - 参数值public static int nextInt(int bound)
bound - 最大Copyright © 2024. All rights reserved.