Another new feature in Java 7 is the WatchService API[1], which allows one to watch a directory for file changes (implemented using native filesystem methods). Previously, this could only be done with polling[2] or custom native code called through JNI.
It only falls back to polling if there is no support for using the native filesystem method.
You don't have to use `poll()`, you can use `take()` which is the blocking equivalent to it. In fact, in most use cases I would imagine you would spawn a thread and use `take()`. I'm guessing they called it `poll()` as it is non-blocking, so if you don't get a result then you have to keep calling it. However, I don't think it reflects the implementation details.
I've been living under a rock(1) and haven't heard about all those new additions in Java 7:
> The additions with this release are useful, for example Try with resources – having closable resources handled automatically from try blocks, Strings in switch statements, multicatch for Exceptions and the ‘<>‘ operator for working with generics.
I've been playing with CoffeeScript and Ruby lately, and was very weirded out by the lack of parentheses in method calls, til I started to see them as bash-like (but more sophisticated of course), where you just add the arguments. Ruby used to be called a "scripting" language after all.
Another characteristic of "scripting" languages is ease of file handling. Java is not a scripting language. Previously, if you wanted to copy from one stream to another, you had to write a loop (maybe you still do, and this "copy" is strictly for files?). Simple; but nice if they provided a cat() method. It's quite amazing how popular Java is (and how useful it must be in other areas), considering this kind of trivial shortcoming.
NIO FileChannels have a transferTo() method[1]. I expect they only added it once they found a good enough reason (zero-copy). The standardization process moves so slow that convenience functions are better served by third-party libraries.
For streaming a loop, the point is they have left that to programmers/library designers to implement these functions. Since there are a number of considerations, buffer size, error management ... etc. it does in fact make sense to not have just one sanctioned implementation for this.
[1]: http://docs.oracle.com/javase/tutorial/essential/io/notifica... [2]: http://jnotify.sourceforge.net/