ResourceBundle

2017-09-21  本文已影响0人  仒叻戓厺

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

}

}

}

上一篇下一篇

猜你喜欢

热点阅读