本文整理汇总了Java中org.apache.commons.vfs2.impl.DefaultFileMonitor.setDelay方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultFileMonitor.setDelay方法的具体用法?Java DefaultFileMonitor.setDelay怎么用?Java DefaultFileMonitor.setDelay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.vfs2.impl.DefaultFileMonitor
的用法示例。
在下文中一共展示了DefaultFileMonitor.setDelay方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFileModified
import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public void testFileModified() throws Exception
{
writeToFile(testFile);
FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
monitor.setDelay(100);
monitor.addFile(fileObj);
monitor.start();
// Need a long delay to insure the new timestamp doesn't truncate to be the same as
// the current timestammp. Java only guarantees the timestamp will be to 1 second.
Thread.sleep(1000);
long value = System.currentTimeMillis();
boolean rc = testFile.setLastModified(value);
assertTrue("setLastModified succeeded",rc);
Thread.sleep(300);
assertTrue("No event occurred", changeStatus != 0);
assertTrue("Incorrect event", changeStatus == 1);
monitor.stop();
}
示例2: testFileRecreated
import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public void testFileRecreated() throws Exception
{
FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
monitor.setDelay(100);
monitor.addFile(fileObj);
monitor.start();
writeToFile(testFile);
Thread.sleep(300);
assertTrue("No event occurred", changeStatus != 0);
assertTrue("Incorrect event " + changeStatus, changeStatus == 3);
changeStatus = 0;
testFile.delete();
Thread.sleep(300);
assertTrue("No event occurred", changeStatus != 0);
assertTrue("Incorrect event " + changeStatus, changeStatus == 2);
changeStatus = 0;
Thread.sleep(500);
monitor.addFile(fileObj);
writeToFile(testFile);
Thread.sleep(300);
assertTrue("No event occurred", changeStatus != 0);
assertTrue("Incorrect event " + changeStatus, changeStatus == 3);
monitor.stop();
}
示例3: testFileCreated
import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public void testFileCreated() throws Exception
{
FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
monitor.setDelay(100);
monitor.addFile(fileObj);
monitor.start();
writeToFile(testFile);
Thread.sleep(300);
assertTrue("No event occurred", changeStatus != 0);
assertTrue("Incorrect event", changeStatus == 3);
monitor.stop();
}
示例4: testFileDeleted
import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public void testFileDeleted() throws Exception
{
writeToFile(testFile);
FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
monitor.setDelay(100);
monitor.addFile(fileObj);
monitor.start();
testFile.delete();
Thread.sleep(300);
assertTrue("No event occurred", changeStatus != 0);
assertTrue("Incorrect event", changeStatus == 2);
monitor.stop();
}
示例5: watch
import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public void watch() throws FileSystemException {
FileSystemManager manager = VFS.getManager();
FileObject file = manager.resolveFile(
this.compassCompiler.getConfigFile().getParentFile().getAbsolutePath());
DefaultFileMonitor fm = new DefaultFileMonitor(new CompassWatchListener(this.compassCompiler));
fm.setRecursive(true);
fm.setDelay(2000);
fm.addFile(file);
fm.start();
}