java – Checking for adding a file to a folder


I have a service that must constantly check a specific folder, and when adding a file to a folder, it must perform certain actions. Question: how to catch the event of adding a file to a folder?


Took the answer from the link in the comment to my question:

observer = new FileObserver("путь до папки") { 

             public void onEvent(int event, String file) {
                if(event == FileObserver.CREATE){ 

                 "какое-либо действие при добавлении файла"

Scroll to Top