Page 1 of 1

[CODE] FolderWatchService

Posted: 21 Jul 2012, 10:37
by rednoah
Here's a basic example for watching folders for new files. It'll just print the added/changed files.

Code: Select all

// watch folders and print files that were added/modified (requires Java 7)
def watchman = args.watch { files ->
	println files
}

// process after 500ms without any changes to the folder
watchman.commitDelay = 500        // default = 5min
watchman.commitPerFolder = true   // default = true

println 'Waiting for changes'
console.readLine() // keep running and watch for changes