我是靠谱客的博主 辛勤魔镜,这篇文章主要介绍Java 模板变量替换——字符串替换器{}、${}、${}map,现在分享给大家,希望可以做个参考。

// 直接使用hutool工具类即可
// format("this is {} for {}", "a", "b") = this is a for b
StrFormatter.formatWith("aa ${}", "${}", "b")
// format("this is {} for {}", "{}", "a", "b") = this is a for b
StrFormatter.formatWith("aa {}", "b")
  
// format 格式化文本,使用 {varName} 占位<br>
// map = {a: "aValue", b: "bValue"} format("{a} and {b}", map) ---= aValue and bValue

最后

以上就是辛勤魔镜最近收集整理的关于Java 模板变量替换——字符串替换器{}、${}、${}map的全部内容,更多相关Java内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(136)

评论列表共有 0 条评论

立即
投稿
返回
顶部