Hello everyone!

I am a newbie in java and I have to build a server to handle http requests.
When I read request from socket, my inputStream is never ending as the client doesn't close connection after sending the request.

while ((line = in.nextLine())!= null) {
System.out.println("1");
if (line.equals("")) {
break; // quit while loop when last line of header is reached
}

else
request = request + line + "\n";
}



I also want to read the body of the request, but I don't know when to end that reading stream...
Any pointers and help will be welcome...