Schwatcher: File-watching library for Scala. Built on Java 7's WatchService and Akka actors.
Schwatcher
A library that wraps the WatchService API of Java7 and allows callbacks to be registered on both directories and files.
Xitrum contain Schwatcher inside it, and provide quick utility.
import xitrum.util.FileMonitor
val target = FileMonitor.pathFromString("path_relative_to_application_root")
FileMonitor.monitor(FileMonitor.MODIFY, target, { path =>
// Do some callback with path
println(s"File modified: $path")
// And stop monitoring if necessary
FileMonitor.unmonitor(FileMonitor.MODIFY, target)
})
Written by Takeharu.Oshida
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Scala
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#