2

How to monitor file or directory changes?

Share:

Filed in: Java IO

2 Responses to "How to monitor file or directory changes?"

  1. Srin says:

    Found this a very useful example to understand watchservice..

    In the SOP , i added event.context() to know what file has changed.

    if (kind == ENTRY_CREATE) {
    System.out.println(“Entry was created on log dir.:”+event.context());
    } else if (kind == ENTRY_MODIFY) {
    System.out.println(“Entry was modified on log dir.:”+event.context());
    } else if (kind == ENTRY_DELETE) {
    System.out.println(“Entry was deleted from log dir.:”+event.context());
    }

    • Srin says:

      I apologize ; In your next article i see the example to know the file name.
      ((Path)event.context()).getFileName()

      Thanks for your examples.

Leave a Reply

Submit Comment

© 2014 Java Examples - Developed with