theInput = new DataInputStream(in);
try { while (true) { System.out.println(theInput.readInt()); } } catch (IOException ex) { if (ex.getMessage().equals("Pipe broken") || ex.getMessage().equals("Write end dead")) { // normal termination return; } ex.printStackTrace(); }