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
1 answer

Manage a pool of daemons threads

I have to handle a group of daemons that each implement a watchservice. What I want to be able to do is, create the daemons, activate them, deactivate and remove. At the moment at creation I do this to activate: private void…
Sven
  • 1,133
  • 1
  • 11
  • 22
0
votes
0 answers

Singleton WatchServiceHandler class doesn't print

I have a singleton Handler class that is instantiated like this: public static synchronized Singleton getInstance() { if (instance == null) instance = new Singleton(); return instance; } At the creation it creates a couple of…
Sven
  • 1,133
  • 1
  • 11
  • 22
0
votes
1 answer

Issue invoking WatchService inside a singleton bean

we wanted to watch a file periodically for changes, we are using jboss 7 . Following is my code snippet. I initialized the watcher in the postconstruct method of singleton bean and scheduled a method to poll watch events. I could observe the changes…
Saravana
  • 303
  • 1
  • 6
  • 12
0
votes
3 answers

Sequentially processing file in threadpool executor

we use JDK 7 watchservice to watch directory which can have xml or csv files. These files are put in threadpool and later on processed and pushed into database.This application runs for ever watching the directory and keeps processing files as and…
0
votes
1 answer

StandardWatchEvents.ENTRY_MODIFY triggers with modifying a subfolder?

Example: I have my desktop with a subfolder "Desktop/sub" if only Desktop is registered and once started the WatchService I modify the content of a subfolder.. should it trigger an ENTRY_MODIFY or not? I tried and it does not. It works only for…
Rollerball
  • 12,618
  • 23
  • 92
  • 161
0
votes
1 answer

WatchService loop running twice unless stepping through in debug mode

I am really new to WatchService and I am having a very interesting bug. When I run my code in normal mode(Run) it will loop through the for(Watch event: key1.pollEvents()) loop twice and create two google calander events but if I step through it…
N1mr0d
  • 493
  • 5
  • 11
0
votes
0 answers

How to fire an event on file when file modification has stopped in Java using WatchService?

I have been using WatchService api to implement this. I want to check whether a file is unchanged for 10 seconds and if it is so, then process the file. I have developed a code which checks whether file has been modified or not i a directory but…
Parijat Bose
  • 380
  • 1
  • 6
  • 22
0
votes
2 answers

How could I omit detection for some files with Java 7 WatchService

I've registered CREATE, MODIFY and DELETE events to the monitor successfully and they works fine to me. For my issue I would like to do some file modification like 'rename' once CREATE event is triggered so MODIFY event will be triggered next as…
Tiggaroo
  • 3
  • 3
0
votes
1 answer

Unexpeced output of java 7 nio 2 program

I am trying a small program from Pro Java 7 NIO.2 Page No 118 Code is : class WatchRafaelNadal { public void watchRNDir(Path path) throws IOException, InterruptedException { try (WatchService watchService =…
Vikram
  • 1,999
  • 3
  • 23
  • 35
0
votes
1 answer

Java7: Detect all files when creating a new non-empty directory

I'm implementing a WatchDog to look recursively for file changing, deleting and adding in a directory, I'm using linux. The program works well and doing it with Java7 is pretty straightforward, the only thing is that when I add a directory with some…
Perennialista
  • 1,083
  • 2
  • 12
  • 22
-1
votes
0 answers

File Monitoring failed suddenly for shared folder, Java WatchService

Why has File Monitoring using WatchService in Java 8 for a shared folder mapped to a file server suddenly stopped working without any exceptions appearing in the logs? What could be the potential cause for this issue? We are not getting Exception.…
-2
votes
1 answer

monitor a Folder and extract all data in the file using java

am trying to monitor a folder/file for any changes and then extract all the data from the file and append it to the database using java. i have tried the watch service api in java to monitor the file as shown in the code snippet below. import static…
mherman22
  • 1
  • 2
-2
votes
2 answers

How i can make a Watch Service that deletes a file when it closes?

I basically want to make a watch service (or something like it) that checks if a file has been closed and instantly remove that file if it did close(finished executing). How I can achieve this? please give me a cmd commands or some code(i prefer…
Eboubaker
  • 618
  • 7
  • 15
1 2 3
14
15