Read the API doc for the hasNext method it may block waiting for more input.

For suggestions, post a small program that demonstrates your problem.