You could use a Socket with a timeout set.

As explained here - java - can i speed up the scanning port process? - Stack Overflow

Also see - http://www.antionline.com/showthread.php?t=255698