@FXML
    void exportarCSV(ActionEvent event) {
        File file = Util.showSaveChooser();
        if (file != null) {
            BufferedWriter wr = null;
            try {
                Table get = connection.getDatabase().getTables().get((String) ((TreeItem) dataBases.getSelectionModel().getSelectedItem()).getValue());
                List<Map<String, String>> reload = reload(get);
                wr = new BufferedWriter(new FileWriter(file));
                for (Map<String, String> dado : reload) {
                    Iterator<Column> iterator = get.getColumns().iterator();
                    while (iterator.hasNext()) {
                        Column col = iterator.next();
                        if (dado.containsKey(col.getNome())) {
                            if (col.getTipo().equalsIgnoreCase("character varying")) {
                                wr.write("\"" + dado.get(col.getNome()) + "\"");
                            } else {
                                wr.write(dado.get(col.getNome()));
                            }
                        }
                        if (iterator.hasNext()) {
                            wr.write(",");
                        }
                    }
                    wr.write("\n");
                }
            } catch (IOException ex) {
                Logger.getLogger(appViewController.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                try {
                    wr.close();
                } catch (IOException ex) {
                    Logger.getLogger(appViewController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }