ResourceBundle读取properties文件
public class Test {
public static void main(String[] args) {
//方式一测试ResourceBundle
// ResourceBundle resourceBundle = ResourceBundle.getBundle("public_user");
// System.out.println(resourceBundle.getString("IS_DEV_STATUS"));
// System.out.println(resourceBundle.getString("USE_KEYBOARD"));
//方式二
InputStream in =Test.class.getClassLoader().getResourceAsStream("public_user.properties");
Properties pro =new Properties();
try {
pro.load(in);
System.out.println(pro.get("USE_KEYBOARD"));
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}
网友评论