Properties 使用

   try {
        private Properties prop = new Properties();


FileReader fr = new FileReader("conf" + File.separator + "config.properties");
BufferedReader br = new BufferedReader(fr);
prop.load(br);
br.close();
} catch (FileNotFoundException e) {
new Alert(Alert.AlertType.NONE, "未找到配置文件config.properties", new ButtonType[]{ButtonType.CLOSE}).show();
} catch (Exception e) {
e.printStackTrace();
}


建议用下边这个
String conf = System.getProperty("user.home") + File.separator + "conf.properties";
FileInputStream fis = new FileInputStream(conf);
prop.load(fis);
fis.close();
posted @ 2017-04-13 09:17  范世强  阅读(275)  评论(0编辑  收藏  举报