2014-08-27 46 views
0

我正在阅读属性文件中的文本,文本为your deals ends on $enddate。现在,我想在使用getProperty方法检索后,将endate替换为我的类中的特定日期。Java属性文件替换检索字符串

String info = props.getProperty(“message”);

属性文件包含

消息=您的交易在$结束日期

+1

你知道那'String'类有一个方法'replace()'和'replaceA LL()'? – 2014-08-27 10:29:17

+0

你最好使用'MessageFormat'。 – BalusC 2014-08-27 10:30:23

回答

3

在性能结束文件:

message=your deals ends on {0} 

,并在Java类:

MessageFormat.format((String) props.get("message"), dateToReplace);