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);
}
}