BufferedReader issue - doesn't respond properly
<p>I found this TCP server online, I want to modify it a little bit to return different message than was typed in the client. It doesn't work as I want; the <code>else {}</code> works "like a charm" but the first if doesn't - the client is still waiting for input.</p>

<p>server.java</p>

<pre><code>while(true)
{
Socket connectionSocket = welcomeSocket.accept();
BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
clientSentence = inFromClient.readLine();
System.out.println("Received: " + clientSentence);
String test="hey";
String tempus="tster";
if(clientSentence.contains(test)==true){
System.out.println(tempus);
outToClient.writeBytes(tempus);
}
else{
capitalizedSentence = clientSentence.toUpperCase() + '\n';
outToClient.writeBytes(capitalizedSentence);
}
</code></pre>

<p>client.java</p>

<pre><code>public static void main(String argv[]) throws Exception
{
String sentence;
String modifiedSentence;
BufferedReader inFromUser = new BufferedReader( new InputStreamReader(System.in));
Socket clientSocket = new Socket("localhost", 6789);
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
sentence = inFromUser.readLine();
outToServer.writeBytes(sentence + '\n');
modifiedSentence = inFromServer.readLine();
System.out.println("FROM SERVER: " + modifiedSentence);
clientSocket.close();
}
</code></pre>
