Replace a for-range loop by a while loop in javalib.

It was on the path of Predef.println(), which is worth
making not too slow. Besides, it was the only for-range
loop in javalib.
Merge pull request #325 from sjrd/while-loop-in-javalib

Replace a for-range loop by a while loop in javalib.