Get String From Stream and append it in the TextArea

hi i wrote a simple network program in java and i have this problem

i when i get the data from the stream i can't append it in the TextArea

and this is the code :

/*

* Main.java

*

*

* To change this template, choose Tools | Template Manager

* and open the template in the editor.

*/

package javaclient;

/**

*

* @author JAD

*/

import java.net.*;

import java.io.*;

import java.lang.Thread.*;

import java.awt.*;

import javax.swing.*;

import javax.swing.SwingUtilities;

import javax.xml.bind.ParseConversionEvent;

import java.util.*;

publicclass Mainimplements Runnable{

private javax.swing.JTextField IpAddress;

private javax.swing.JTextField Port;

private javax.swing.JTextArea Inputline;

private javax.swing.JTextArea ReciveText;

static BufferedReader in =null;

static PrintWriter out =null;

staticprivate Socket theClientSocket =null;

staticprivate String message ="";

public Main(JTextArea Inputline,JTextArea ReciveText , JTextField IpAddress,JTextField Port){

this.Port=Port;

this.Inputline=Inputline;

this.ReciveText=ReciveText;

this.IpAddress=IpAddress;

}

publicvoid Send()

{

out.println(Inputline.getText());

}

publicvoid run()

{

try{

//Instantiate a new Socket

theClientSocket =new Socket(IpAddress.getText(),Integer.parseInt(Port.getText()));

in =new BufferedReader(new InputStreamReader(theClientSocket.getInputStream()));

out =new PrintWriter(theClientSocket.getOutputStream(),true);

do

{

// Step 3: processing phase

try

{

// read message from server

final String message = in.readLine();

ReciveText.append(message +"\n");

}// end try

catch ( Exception ev )

{

// handle exception if error in reading server data

System.exit(1);

}// end catch

}while ( message !="TERMINATE" );

// Step 4: close connection

theClientSocket.close();

in.close();

out.close();

System.exit(1);

}// end try

catch (Exception error)

{

}// end catch

}

}

the problem is in this statment

ReciveText.append(message + "\n");

and the thing that me crazy the program exit when i send

TERMINATE

but the data doesn't appear in the TextArea

Any one here can help me

[4875 byte] By [JAD271a] at [2007-11-26 16:54:07]
# 1
Everything seems to be ok.i dnt think that there is a problem with TextArea.append(). i worked on the same thing in the past.Append function does not work if the string given into it is empty. so try to know wehether you are geeting your desired data from the BufferedReader or not.
barjeshbarrya at 2007-7-8 23:21:45 > top of Java-index,Java Essentials,Java Programming...
# 2

1. Your while will never end:

You should use

while ( !message.equals("TERMINATE"));

instead of

while ( message != "TERMINATE" );

Your Main terminates by getting an exception when you close the socket on the other side and then you call System.exit in your catch.

2. You should call OuputStream.flush on the ouput stream when you want to send a line.

Rodney_McKaya at 2007-7-8 23:21:45 > top of Java-index,Java Essentials,Java Programming...