2014-08-27 50 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);