现在的位置: 首页 > 综合 > 正文

Properties的用法

2018年02月03日 ⁄ 综合 ⁄ 共 398字 ⁄ 字号 评论关闭

File file = new File("./mail.properties");
        FileInputStream pInStream = null;
        try {
            pInStream = new FileInputStream(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        Properties pro = new Properties();
        try {
            pro.load(pInStream);
        } catch (IOException e) {
            e.printStackTrace();

        }

pro.getProperty("mailHost") 就可以得到String类型的valuel了。

mail.properties示例:

mailHost = 10.20.2.42

抱歉!评论已关闭.