美文网首页
ResourceBundle

ResourceBundle

作者: 仒叻戓厺 | 来源:发表于2017-09-21 09:24 被阅读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();

    }

    }

    }

    相关文章

      网友评论

          本文标题:ResourceBundle

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