コード例 #1
0
 private void saveServers() {
   File serverDir = new File(settings.getLocalFolder(), "servers");
   if (!serverDir.exists()) {
     serverDir.mkdirs();
   }
   for (Server s : model.getAllServers()) {
     try {
       File serverFile = new File(serverDir, s.getName() + ".server");
       s.writeToFile(serverFile);
     } catch (IOException ex) {
       logger.log(Level.SEVERE, null, ex);
     }
   }
 }
コード例 #2
0
 public void deleteKnownServer() {
   Server currentServer = model.getCurrentServer();
   if (currentServer != null) {
     try {
       model.removeServer(currentServer);
       File serverDir = new File(settings.getLocalFolder(), "servers");
       File serverFile = new File(serverDir, currentServer.getName() + ".server");
       Files.delete(serverFile.toPath());
     } catch (IOException ex) {
       model.addErrorMessage("Server-Datei konnte nicht gelöscht werden");
       logger.log(Level.SEVERE, null, ex);
     }
     model.fireChange();
   }
 }