private void maybeInitializeWatchService() throws IOException { if (watchFileChanges) { stopWatchService(); try { watchService = FileSystems.getDefault().newWatchService(); } catch (IOException e) { watchFileChanges = false; } } }
public void shutdown() throws IOException { // watchService field is not cleared so any attempt to use this class after shutdown will fail. stopWatchService(); }