类 TirsciUtil

java.lang.Object
cn.sinozg.applet.common.utils.TirsciUtil

public class TirsciUtil extends Object
工具类 自己用
  • 字段详细资料

    • log

      private static final org.slf4j.Logger log
    • random

      private static final SecureRandom random
  • 构造器详细资料

    • TirsciUtil

      private TirsciUtil()
  • 方法详细资料

    • tryCatch

      public static <T> T tryCatch(SupplierException<T> supplier)
      异常捕获起来
      类型参数:
      T - 类型
      参数:
      supplier - 要执行的方法
      返回:
      返回数据
    • format

      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 - 参数值
      返回:
      格式化后的文本
    • nextInt

      public static int nextInt(int bound)
      随机整数 [0,bound)
      参数:
      bound - 最大
      返回:
      整数