I'm trying to read lines from a BufferedReader in java by using a while loop. It will traverse through the BufferedReader as should, but when it should break from the loop it will 'freeze' the execution of the code. I've tried debugging the code but it the execution cue is lost after the loop. No idea what I'm doing wrong:
Code snippet:
BufferedReader reader = new BufferedReader(new InputStreamReader(yourSocket.getInputStream()));
String nextLine = null;
nextLine = reader.readLine();
while (nextLine != null){ //print all of input stream
System.out.println(nextLine);
nextLine = reader.readLine();
}
I've assumed that when there are no lines left in the BufferedReader that the nextLine variable would return null and break the loop. I've tried breaking the loop manually but it doesn't seem to work neither. Again, the code would print the BufferedReader's lines fine but any code following the while loop will not necessarily run.
If this info is not enough, please let me know. I can also past the full code if necessary.
Thanks, Pat