Questions tagged [watchservice]

WatchService is a Java API for watching changes on a filesystem. It was introduced in Java 7.

WatchService is a Java API for monitoring file systems for changes. It can be used to detect new files, modified files or file deletions. It was introduced in Java 7 and is part of the (new) NIO system.

223 questions
0
votes
0 answers

The WatchEvent's context doesn't reflect renaming of the directory

I'm trying to implement a recursive directory watching functionality. But I found the API very hard to understand. Let's say I have an empty directory which is the root of the directory tree I would like to watch. Now I create a new directory within…
Jan Krakora
  • 2,500
  • 3
  • 25
  • 52
0
votes
0 answers

Which Operating Systems have Native File Event Notification Facility? Do all Windows versions have it?

I read that WatchService API in Java 7 requires a Native File Event Notification Facility or otherwise it will use polling. Which OS have this facility? Is there a version in Windows that does not have it?
p192
  • 518
  • 1
  • 6
  • 19
0
votes
1 answer

JNotify vs Polling

I am working with Java 6 and can not use Watch Service. I am looking for an alternative to polling. So how is JNotify different from polling? Or does JNotify uses polling?
p192
  • 518
  • 1
  • 6
  • 19
0
votes
0 answers

WatchService OVERFLOW - what happens and how can my files be safely processed?

I'm thinking of refactoring my current cronjob based filemonitoring (running every night) with a more dynamic file monitoring. Reading the documentation it mentions OVERFLOW – Indicates that events might have been lost or discarded. You do not…
Viktor Mellgren
  • 4,318
  • 3
  • 42
  • 75
0
votes
0 answers

Using WatchService to identify changes in .txt

I am attempting to scan through a directory for any changes to multiple files using the WatchService. I am able to identify the exact text file in the given directory that has been changed. I am wondering if there is some way to have my program…
0
votes
1 answer

WatchService: passing parameter at registration

I'm looking for a way to pass parameters when registering a Path to a WatchService. The goal is to get those parameters when processing events related to the Path. WatchService watchService =…
manash
  • 6,985
  • 12
  • 65
  • 125
0
votes
2 answers

Get information about changed file in Java

I'm trying to monitor files in java. When a file modification will happen I want to know: Which process did the change. What has changed. Also, I know that there is a way to change the "last modified date" in a file, so I want to check if someone…
0
votes
2 answers

Java append text and save file continously

I would like to generate line of words continously and append to a text file. As I am using WatchService, I would want to get the line appended immediately. WatchService require me to do a "Save" before it detect the modification to the file and…
chj
  • 91
  • 9
0
votes
0 answers

Java WatchService watches not terminated

I'm working on an application that uses the Java watchservice (Java 8) under Linux Mint. One interesting problem I am encountering is running out of inotify watches. I'm developing under Eclipse and the behavior is as follows: When the app starts,…
Joel Graff
  • 167
  • 15
0
votes
1 answer

Testing code using a watch service

I'm trying to unit test a small piece of logic that is using WatchService (Java 7). Although, this is proving to be more difficult than anticipated because of the infinite loop: watchService.take(); while (key!=null) { for (WatchEvent ev :…
user4120423
0
votes
1 answer

Ensure folder tree is complete before continuing

I am writing a hotfolder-type program where files+folders dragged into my designated upload folder are uploaded to a cloud service. Quick overview of how I want to do this: WatchService notifies me that something has been dragged into the…
jahmezz
  • 416
  • 1
  • 5
  • 15
0
votes
1 answer

Watching a Directory for Changes Java.nio.file

I know java.nio.file could provide ways to watch file's change like new file ,modify and delete . but now I wonder if there's a way to watch if the directory is being entered or one file being opened by some app like a editor. I've read the API…
Adams.H
  • 1,603
  • 4
  • 20
  • 29
0
votes
1 answer

Java WatchService doesn't work on some folders

I want to use Java 7 WatchService to monitor /proc folder, but that's not working (changes made in the folder are not reported). I've tested other folders such as /home/user/Desktop and /tmp and it works. What could be the reason? Is it because of…
Caballero
  • 11,546
  • 22
  • 103
  • 163
0
votes
2 answers

Java 7 WatchService -- ENTRY_MODIFY triggered on file open

I have a program that watches a directory for file update using WatchService. I get events when I modify a file. However, I notice that even if I open a file in vi, and do not modify its contents, the watch service poll method is invoked. My code is…
user2881767
  • 190
  • 8
0
votes
2 answers

Can't stop a ExecutorService

I try to end a ExecutorService with executorService.shutdown(); and if that didn't worked, with executorService.shutdown();. The Problem is, that the executorService can't be stopped and the program is still running. Here is my class which shall…
Peter
  • 1,679
  • 2
  • 31
  • 60
1 2 3
14
15