Beispiel #1
0
  public FileChecker(int linienCount) {
    lineReader = new Vector<LineReader>(linienCount);
    running = true;

    Path dir = Paths.get(Controller.getPath("."));
    try {
      watcher = FileSystems.getDefault().newWatchService();
      dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE);
    } catch (IOException e) {
      watcher = null;
      e.printStackTrace();
    }

    if (watcher != null) start();
  }
Beispiel #2
0
  public void exit() {
    try {
      running = false;
      watcher.close();
    } catch (IOException e) {
      e.printStackTrace();
    }

    File folder = new File(Controller.getPath("."));
    File[] folderFiles = folder.listFiles();
    if (folderFiles == null) return;

    for (File file : folderFiles) {
      if (file.getName().matches(".*\\.((nrt)|(ctl)|(dat)|(def))")) {
        if (!file.delete()) {
          System.err.println("Can't remove " + file.getAbsolutePath());
        }
      }
    }
  }