How to monitor file or directory changes?

  • Srin

    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

      I apologize ; In your next article i see the example to know the file name.

      Thanks for your examples.