美文网首页Java笔记
使用ResourceBundle读取properties文件

使用ResourceBundle读取properties文件

作者: 你好小Song | 来源:发表于2018-05-31 21:00 被阅读0次

1.定义一个message.properties

name=jack

2.编写程序

package com.test;

import java.util.ResourceBundle;

public class TestDemo {
    public static void main(String[] args) {
        // 这里不需要写*.properies后缀,如果文件定义在包中,前面需要加上包名称,如com.tet.message
        ResourceBundle res = ResourceBundle.getBundle("message");
        String name = res.getString("name");
        System.out.println(name);
    }
}

相关文章

网友评论

    本文标题:使用ResourceBundle读取properties文件

    本文链接:https://www.haomeiwen.com/subject/akscsftx.html