java - do while didn't go to next line even though it should end -
i'm on socket project. when i'm debuging code found problem can't find out why, below code
// code open socket connection , put inputstream bufferedreader called 'in' string input; input= (string)in.readline(); do{ system.out.println(input); }while(input!=null); out.close(); in.close(); socket.close(); as can see, above code create infinite loop, when send string server side, keeps println string.
if below
string input; do{ input= (string)in.readline(); system.out.println(input); }while(input!=null); out.close(); in.close(); socket.close(); the problem solved , , works great. every time send string server site, print once. didn't exit loop , go next line close socket connection .
so here question. if put within while loop. should loop end , go next line disconnect connection?? can explain why while loop execute once , didn't go next line?
best
if input= (string)in.readline(); in do-while loop, when read in null, print null , exit loop. then, out.close();,in.close();, , socket.close(); execute.
Comments
Post a Comment