Java教程

集合10、集合_Map接口_Properties的使用

本文主要是介绍集合10、集合_Map接口_Properties的使用,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Properties的使用

public static void main(String[] args) {

    FileInputStream fis = null;
    try {
        Properties props = new Properties();

        fis = new FileInputStream("jdbc.properties");
        props.load(fis);    //加载流对应的文件

        String name = props.getProperty("name");
        String password = props.getProperty("password");

        System.out.println("name = " + name + ",password = " + password);
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
这篇关于集合10、集合_Map接口_Properties的使用的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!