I can't figure out why this wouldn't work:
private String clientInput() { String temp = ""; try { temp = in.readLine().trim(); if (temp == null) { out.println("4"); out.flush(); } } catch (IOException ioe) { out.println("6"); out.flush(); } return temp; } At the moment I have that method which should read input from a 'client' socket, 'in' is a bufferedReader, 'out' is a printwriter. I am supposed to make sure the program is robust enough to handle if the user ends the session unexpectedly. So when waiting for the user to input, I figured if they ended the session the input would end up being null. (is that right?) so I have a test class that sends the following data across:
String[] title = {"a","b","c","","e","f",null}; just to test that it would catch the null value...but it doesn't.
Just for reference the line that sends the values across is in a loop:
out.println(title[i]); out.flush(); Have I got the wrong idea? or am I just doing something wrong?
thanks abarnybox