I have a program that listens to a port from a server that sends XML messages. I listen and get the XML through a URL connection and then read in the stream like this below. The problem is it seems to hang up when it gets the last tag from the XML. By hang up, I mean when I step through the code at gets at clientStream.read after a couple iterations, my debugger stays at "stepping" forever and the program never ends until I terminated it. What can be the problem? I was trying to see if I can get the length of the incoming stream so I can tell the loop to run until it reaches the end, but I don't know how to do that. Does somebody know? Thanks. I've tried different ways of reading the stream like reading it line by line but I get same result.
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
BufferedReader inData = new BufferedReader(in);
InputStream clientStream = client.getInputStream();
while ((readstream=clientStream.read()) >= 0)
if ( readstream == 13 ) continue;
reqData[i] = (char)readstream;