java socket can't send message using BufferedWriter
<p>I am trying to use <code>BufferedWriter</code> to send a message to the server from the client or server to client. However nothing will send, but it will listen if you send a message to it. I am not sure what I am doing wrong but I think the problem is from here.</p>

<pre><code>ActionListener buttonActive= new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                messageTextArea.append(textMessage.getText()+ "\n");
                sendText = textMessage.getText();
            }
        };
        sendButton.addActionListener(buttonActive);

    private void startSending(){

        SwingWorker &lt;Void, Void&gt; sendingThread = new SwingWorker &lt;Void, Void&gt;(){
            protected Void doInBackground() throws Exception {

                BufferedWriter writer = null;
                writer = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
                while(connected){
                    writer.write(sendText);
                    writer.flush();
                }
                return null;
            }
        };
        sendingThread.execute();
    }
</code></pre>

<p>@trashgod and @madProgrammer gave me a solution using printWriter which works but I want me to make a few more version using <code>BufferedWriter</code>+<code>BufferedReader</code>, <code>OutputStream+ InputStream</code> and <code>BufferedWriter</code>+<code>PrintWriter</code>, however i want to make the <code>BufferedWriter</code>+<code>BufferedReader</code>.</p>
