Inotify-java is a Java library that monitors changes to the file system under Linux. Example code:
- try {
- Inotify i = new Inotify ();
- Inotifyeventlistener e = new Inotifyeventlistener () {
- @Override
- public void filesystemeventoccurred (Inotifyevent e) {
- System.out.println ("INotify event occurred!");
- }
- @Override
- public void Queuefull (Eventqueuefull e) {
- System.out.println ("inotify event queue:" + e.getsource () +
- "Is full!");
- }
- };
- I.addinotifyeventlistener (e);
- I.addwatch (System.getproperty ("User.home"), constants.in_access);
- } catch (Unsatisfiedlinkerror e) {
- SYSTEM.ERR.PRINTLN ("Unsatisfied link error");
- } catch (Userlimitexception e) {
- System.err.println ("User limit exception");
- } catch (Systemlimitexception e) {
- SYSTEM.ERR.PRINTLN ("System limit Exception");
- } catch (Insufficientkernelmemoryexception e) {
- SYSTEM.ERR.PRINTLN ("Insufficient kernel memory exception");
- }
|
More Java,java learning, Java face Test http://techfoxbbs.com
"Linux File system monitoring Java class Library Inotify-java"