保存到properties

@FXML
private void savaconfig(ActionEvent event) {
try {
Properties prop = new Properties();
FileWriter fw = new FileWriter("conf" + File.separator + "config.properties");
BufferedWriter br = new BufferedWriter(fw);

String sqlmapPath = this.id_textFeild.getText();

prop.setProperty("SqlmapPath", sqlmapPath);

prop.store(br, "配置文件");

br.close();
new Alert(Alert.AlertType.NONE, "已保存到配置文件config.properties", new ButtonType[] { ButtonType.CLOSE }).show();
}
catch (Exception e) {
new Alert(Alert.AlertType.NONE, "未找到配置文件config.properties", new ButtonType[] { ButtonType.CLOSE }).show();
e.printStackTrace();
}
}
posted @ 2017-04-16 22:43  范世强  阅读(239)  评论(0编辑  收藏  举报