NIO File operations in Java 7

By dave on October 23, 2013

Hot on the heals of the last article, interested in what other goodies may be in the new file IO package, and wanting to try the new catch block, I cooked up another example. In this example, I create a Path object for an example directory, into which I then create a file and write some text into the file. Some things of note here: We do not need to concern ourselves with closing the writer objects as they are opened in the new auto-close section.

Watching files in Java 7 with WatchService

By dave on October 23, 2013

In this article I show how to watch files and directories for additions/changes/deletions using the new file system support in Java 7. Finally, after years of native solutions, it is now possible to listen for file changes without resorting to OS specific solutions. In the code below, first we use the new file system support class Paths to get a Path object that represents our particular directory. We then create a watching service, that we will use to listen for changes and finally we register our path (directory) with the watcher for files that are created.

tcMenu for Arduino

We use cookies to analyse traffic and to personalise content. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Please see our privacy policy should you need more information or wish to adjust your settings.