类org.apache.commons.io.monitor.FileAlterationListenerAdaptor源码实例Demo

下面列出了怎么用org.apache.commons.io.monitor.FileAlterationListenerAdaptor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: MercuryTrade   文件: FileMonitor.java
public void start() {
    String gamePath = Configuration.get().applicationConfiguration().get().getGamePath();

    File folder = new File(gamePath + "logs");
    this.fileHandler = new MessageFileHandler(gamePath + "logs/Client.txt");
    FileAlterationObserver observer = new FileAlterationObserver(folder);
    monitor = new FileAlterationMonitor(POLLING_INTERVAL);
    FileAlterationListener listener = new FileAlterationListenerAdaptor() {
        @Override
        public void onFileChange(File file) {
            fileHandler.parse();
        }
    };

    observer.addListener(listener);
    monitor.addObserver(observer);
    try {
        monitor.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码2 项目: joal   文件: TorrentFileWatcherTest.java
@Test
public void shouldBuild() {
    try {
        final TorrentFileWatcher watcher = new TorrentFileWatcher(new FileAlterationListenerAdaptor(), torrentsPath);
        watcher.start();
        watcher.stop();
    } catch (final Throwable e) {
        fail("Should Not fail");
    }
}
 
源代码3 项目: joal   文件: TorrentFileWatcherTest.java
@Test
public void shouldFaiToStartWithNonExistingPath() throws IOException {
    final Path directory = Files.createDirectory(torrentsPath.resolve("sub-folder"));
    final TorrentFileWatcher torrentFileWatcher = new TorrentFileWatcher(
            new FileAlterationListenerAdaptor(),
            directory,
            10
    );

    Files.delete(directory);

    assertThatThrownBy(torrentFileWatcher::start)
            .isInstanceOf(IllegalStateException.class);
}
 
源代码4 项目: joal   文件: TorrentFileWatcherTest.java
@Test
public void shouldNotBuildWithNullMonitoredFolder() {
    assertThatThrownBy(() -> new TorrentFileWatcher(new FileAlterationListenerAdaptor(), null))
            .isInstanceOf(NullPointerException.class)
            .hasMessageContaining("monitoredFolder cannot be null");
}
 
源代码5 项目: joal   文件: TorrentFileWatcherTest.java
@Test
public void shouldNotBuildWithNonExistingMonitoredFolder() {
    assertThatThrownBy(() -> new TorrentFileWatcher(new FileAlterationListenerAdaptor(), torrentsPath.resolve("nop")))
            .isInstanceOf(IllegalArgumentException.class)
            .hasMessageContaining("Folder '" + torrentsPath.resolve("nop").toAbsolutePath() + "' does not exists.");
}
 
源代码6 项目: joal   文件: TorrentFileWatcherTest.java
@Test
public void shouldNotBuildWithNullInterval() {
    assertThatThrownBy(() -> new TorrentFileWatcher(new FileAlterationListenerAdaptor(), torrentsPath, null))
            .isInstanceOf(NullPointerException.class)
            .hasMessageContaining("interval cannot be null");
}
 
源代码7 项目: joal   文件: TorrentFileWatcherTest.java
@Test
public void shouldNotBuildWithIntervalLessThan1() {
    assertThatThrownBy(() -> new TorrentFileWatcher(new FileAlterationListenerAdaptor(), torrentsPath, 0))
            .isInstanceOf(IllegalArgumentException.class)
            .hasMessageContaining("interval cannot be less than 1");
}
 
 类所在包
 同包方法