As a relative newbie in the Java world, I am finding many things frustratingly obtuse to accomplish that are relatively trivial in many other frameworks. A primary example i
AFAIK the TCPMon tool takes a similar approach to what you describe. You can take a look at the source code in their SVN browser
Also have a look at WGET-java for the guts of the blocking code.
But do you have to write this in Java? There are a lot of other approaches using JRuby or Rhino to accomplish something like this easily that will run on the JVM but aren't written in Java.