集册 Java实例教程 文件系统监视服务事件选项

文件系统监视服务事件选项

欢马劈雪     最近更新时间:2020-01-02 10:19:05

456
支持的事件类型在StandardWatchEventKinds中定义。

import java.nio.file.FileSystems;

import java.nio.file.Path;

import java.nio.file.Paths;/** n o w j a v a . c o m - 时代Java 提 供 **/

import java.nio.file.StandardWatchEventKinds;

import java.nio.file.WatchService;


public class Main {

  public static void main(String[] args) throws Exception {

    final Path path = Paths.get("C:/folder1");

    WatchService watchService = FileSystems.getDefault().newWatchService();


    path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE,

        
展开阅读全文