java: calling ready() on a BufferedReader is a dodgy way..

..to detect end-of-file

Change-Id: I3b1d5eca3a7424d72b5e3ab741f7407ad7e65193