"Linux File system monitoring Java class Library Inotify-java"

Source: Internet
Author: User
Tags inotify

Inotify-java is a Java library that monitors changes to the file system under Linux.

Example code:


  1. try {

  2. Inotify i = new Inotify ();

  3. Inotifyeventlistener e = new Inotifyeventlistener () {


  4. @Override

  5. public void filesystemeventoccurred (Inotifyevent e) {

  6. System.out.println ("INotify event occurred!");

  7. }


  8. @Override

  9. public void Queuefull (Eventqueuefull e) {

  10. System.out.println ("inotify event queue:" + e.getsource () +

  11. "Is full!");

  12. }


  13. };

  14. I.addinotifyeventlistener (e);

  15. I.addwatch (System.getproperty ("User.home"), constants.in_access);

  16. } catch (Unsatisfiedlinkerror e) {

  17. SYSTEM.ERR.PRINTLN ("Unsatisfied link error");

  18. } catch (Userlimitexception e) {

  19. System.err.println ("User limit exception");

  20. } catch (Systemlimitexception e) {

  21. SYSTEM.ERR.PRINTLN ("System limit Exception");

  22. } catch (Insufficientkernelmemoryexception e) {

  23. SYSTEM.ERR.PRINTLN ("Insufficient kernel memory exception");

  24. }

More Java,java learning, Java face Test http://techfoxbbs.com


"Linux File system monitoring Java class Library Inotify-java"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.