I could not understand this that why to use flush() method of a PrintWriter class?
<p>Why the code here is using <code>flush()</code> method of the <code>PrintWriter</code> class after getting message from <code>messageBox</code> field....?</p>

<pre><code>public void connectToSocket() {

    try {
        Socket socket = new Socket("localhost", 80);
        PrintWriter writer = new PrintWriter(socket.getOutputStream);
        System.out.println("Connected Successfully");
    }
    catch(IOException ex) {    
        ex.printStackTrace();
    }
}

public class sendMessageListener implements ActionListener {    
    try {    
         writer.println(messageBox.getText());
         writer.flush();
    }
    catch(IOException ex) {    
         ex.printStackTrace();
    }
}
</code></pre>
