用JARKATA的COMMONS-VFS监视文件夹的变化

FileSystemManager fsManager = null; FileObject listendir = null; try { fsManager = VFS.getManager(); listendir = fsManager.resolveFile(new File( "./classes/").getAbsolutePath()); } catch (FileSystemException e) { log.error("监视文件夹出错了", e); e.printStackTrace(); } DefaultFileMonitor fm = new DefaultFileMonitor(new FileListener() { public void fileCreated(FileChangeEvent event) throws Exception { monitor(event); } public void fileDeleted(FileChangeEvent event) throws Exception { monitor(event); } public void fileChanged(FileChangeEvent event) throws Exception { monitor(event); } private void monitor(FileChangeEvent event) { FileObject fileObject = event.getFile(); FileName fileName = fileObject.getName(); if (fileName.getBaseName().endsWith(".class")) { reload(); } } }); fm.setRecursive(true); fm.addFile(listendir); fm.start(); 

 

转自:http://www.blogjava.net/quaff/archive/2006/03/02/33229.html

你可能感兴趣的:(exception,File,null)