Merge pull request #9687 from sampada07/JAVA-619

JAVA-619: Split or move core-java-modules/core-java-io-apis module
This commit is contained in:
Josh Cummings
2020-07-18 09:29:08 -06:00
committed by GitHub
4 changed files with 7 additions and 1 deletions

View File

@@ -7,7 +7,6 @@ This module contains articles about core Java input/output(IO) APIs.
- [A Guide to the Java FileReader Class](https://www.baeldung.com/java-filereader)
- [The Java File Class](https://www.baeldung.com/java-io-file)
- [Java FileWriter](https://www.baeldung.com/java-filewriter)
- [Differences Between the Java WatchService API and the Apache Commons IO Monitor Library](https://www.baeldung.com/java-watchservice-vs-apache-commons-io-monitor-library)
- [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](https://www.baeldung.com/java-path)
- [Quick Use of FilenameFilter](https://www.baeldung.com/java-filename-filter)
- [Guide to BufferedReader](https://www.baeldung.com/java-buffered-reader)

View File

@@ -1,42 +0,0 @@
package com.baeldung.dirmonitoring;
import org.apache.commons.io.monitor.FileAlterationListener;
import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
public class DirectoryMonitoringExample {
private static final Logger LOG = LoggerFactory.getLogger(DirectoryMonitoringExample.class);
private static final int POLL_INTERVAL = 500;
public static void main(String[] args) throws Exception {
FileAlterationObserver observer = new FileAlterationObserver(System.getProperty("user.home"));
FileAlterationMonitor monitor = new FileAlterationMonitor(POLL_INTERVAL);
FileAlterationListener listener = new FileAlterationListenerAdaptor() {
@Override
public void onFileCreate(File file) {
LOG.debug("File: " + file.getName() + " created");
}
@Override
public void onFileDelete(File file) {
LOG.debug("File: " + file.getName() + " deleted");
}
@Override
public void onFileChange(File file) {
LOG.debug("File: " + file.getName() + " changed");
}
};
observer.addListener(listener);
monitor.addObserver(observer);
monitor.start();
}
}