DEV Community

A N M Bazlur Rahman
A N M Bazlur Rahman

Posted on • Originally published at bazlur.com on

How to watch a directory to detect changes using java

Have you ever noticed, when you open a file into two different editors, and when you made changes in one, the other one informs you that the file has changed and you need to reload? How does it do that?

Well, the following coding snippet would do the trick. Let’s watch a particular directory and listen to the event.

100DaysOfProgramming_Day004

for copy/paste pleasure: https://github.com/rokon12/100DaysOfJava/blob/main/src/main/java/com/bazlur/Day006.java

Top comments (1)

Collapse
 
devdufutur profile image
Rudy Nappée • Edited

Warning : it could not work inside a container...

blog.arkey.fr/2019/09/13/watchserv...