theInput = new DataInputStream(in);
try { while (true) { System.out.println(theInput.readInt()); } } catch (IOException e) { // probably just an end of stream exception }