Class StrFormatter

java.lang.Object
com.luna.common.text.StrFormatter

public class StrFormatter extends Object
字符串格式化工具
Author:
Looly
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    format(String strPattern, Object... argArray)
    格式化字符串
    此方法只是简单将占位符 {} 按照顺序替换为参数
    如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
    例:
    通常使用:format("this is {} for {}", "a", "b") =》 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StrFormatter

      public StrFormatter()
  • Method Details

    • format

      public static String format(String strPattern, Object... argArray)
      格式化字符串
      此方法只是简单将占位符 {} 按照顺序替换为参数
      如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
      例:
      通常使用:format("this is {} for {}", "a", "b") =》 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
      Parameters:
      strPattern - 字符串模板
      argArray - 参数列表
      Returns:
      结果