【发布时间】:2014-02-09 12:22:31
【问题描述】:
我经常遇到以下情况:我有很长的多行字符串,其中必须注入属性 - 例如类似模板的东西。但我不想在我的项目中包含一个完整的模板引擎(如velocity 或freemarker)。
如何以简单的方式做到这一点:
String title = "Princess";
String name = "Luna";
String community = "Stackoverflow";
String text =
"Dear " + title + " " + name + "!\n" +
"This is a question to " + community + "-Community\n" +
"for simple approach how to code with Java multiline Strings?\n" +
"Like this one.\n" +
"But it must be simple approach without using of Template-Engine-Frameworks!\n" +
"\n" +
"Thx for ...";
【问题讨论】:
标签: java templating multilinestring