首页 > 代码库 > 保存到properties

保存到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();
}
}

保存到properties