30 lines
739 B
Java
30 lines
739 B
Java
|
|
package zutil.test;
|
||
|
|
|
||
|
|
import java.io.File;
|
||
|
|
import java.io.FileNotFoundException;
|
||
|
|
import java.net.URISyntaxException;
|
||
|
|
|
||
|
|
import zutil.FileChangeListener;
|
||
|
|
import zutil.FileFinder;
|
||
|
|
import zutil.FileWatcher;
|
||
|
|
|
||
|
|
public class FileChangedTest implements FileChangeListener{
|
||
|
|
public static void main(String[] args) throws URISyntaxException, FileNotFoundException{
|
||
|
|
FileWatcher watcher = new FileWatcher(FileFinder.find("test.txt"));
|
||
|
|
watcher.setListener(new FileChangedTest());
|
||
|
|
|
||
|
|
while(true){
|
||
|
|
try {
|
||
|
|
Thread.sleep(10);
|
||
|
|
} catch (InterruptedException e) {
|
||
|
|
// TODO Auto-generated catch block
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void fileChangedEvent(File file) {
|
||
|
|
System.out.println(file);
|
||
|
|
}
|
||
|
|
}
|