java – FileObserver triggers event on self access-ThrowExceptions

Exception or error:

Hello i am using a FileObserver of java to monitor a path, whose contents are updated by some app suppose A and my app.

Now the problem is when app A creates a file in the path, observer detects and triggers the event, then to process the file my app opens the file and do some processing but due to opening, it triggers the same event and thus infinite recursion starts.
I did not find any way to tell FileObserver to not to fire event whenever a file is accessed by my application process.
The code that i am using is following

observer = new FileObserver(path) {

            public void onEvent(int event, String file)
                if(file != null)
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *