read properties file

properties 读取

import java.util.Properties;

public class XX {
    public static void main(String args[]) {
        Properties config = new Properties();
        try {

            BufferedInputStream in = new BufferedInputStream(
                    new FileInputStream("D:/config.properties"));
            config.load(in);
            in.close();
        } catch (IOException e) {
            System.out.println("No AreaPhone.properties defined error");
        }

        String s = config.getProperty("aaAA");
        System.out.println(s);
    }
}
View Code

----------content of D:/config.properties ---------
#fk u :
aaAA=cnm
bbBB=bh
---------------------------------------------------

posted @ 2015-03-18 22:34  牧 天  阅读(163)  评论(0)    收藏  举报