properties配置文件的自定义读取

可以使用一下的工具

package com.qn.core.util;

import java.text.MessageFormat;
import java.util.ResourceBundle;

/**
 * 资源文件工具类
 */
public class ResourceUtil {

    private ResourceBundle resourceBundle;

    private ResourceUtil(String resource) {
        resourceBundle = ResourceBundle.getBundle(resource);
    }

    public static ResourceUtil getResource(String resource) {
        return new ResourceUtil(resource);
    }

    public String getValue(String key) {
        return resourceBundle.getString(key);
    }

    public String getValue(String key, Object... args) {
        String temp = resourceBundle.getString(key);
        return MessageFormat.format(temp, args);
    }

}

猜你喜欢

转载自blog.csdn.net/qiunian144084/article/details/79972290