MessageFormat格式化一个消息

一个简单点的case

package com.zh.tool;

import java.text.MessageFormat;


public class test {
    public static void main(String[] args) {
        String paraString = "xxxxx{0}xxxxx{1}xxxxxxxx{2}xxxxxx";
        System.out.println(MessageFormat.format(paraString.toString(), "para1", "para2", "para3"));
    }
}

结果:

xxxxxpara1xxxxxpara2xxxxxxxxpara3xxxxxx

 

posted @ 2018-01-07 17:31  trypretty  阅读(390)  评论(0编辑  收藏  举报