a question to girionis

hi i have a client server application.
in the server side i have two buttons(3 textfileds), and on the client side have just 4 textfileds
to recive data from server.

the problem is that i can't get the data on the other side by pressing the check button(second one)!!!

here is the code from the server program:

public void actionPerformed(ActionEvent e) {
   if(e.getSource() == send){ // send is a button
       if(e.getSource() ==  check){ //check is a button

the first 3 lines sent (when send button pressed) should be displayed in three textfields(result1,result2,result3) and its working well.
the forth line sent (when the check button pressed) should be displayed in the checkResult in the client GUI which is not working.

here is the client codes witch display those lines:

 s = new Socket("", 1024);
 br = new BufferedReader(new InputStreamReader(s.getInputStream()));
       ps = new PrintWriter(s.getOutputStream(), true);      
       line = new String(); // Line to be read from the server
       line2 = new String(); // another Line to be read from the server
       line3 = new String();// another Line to be read from the server

// While there is more data coming... // this is working well when send button pressed!
while ( (line = br.readLine()) != null &&
(line2 = br.readLine()) != null &&
(line3 = br.readLine()) != null)
    // putting the incomming line from the
    // server into the result fields.
  line4 = new String(); // here is the problem why it can't display data into checkResult field when the check button pressed?!!
   while ( (line4 = br.readLine()) != null){


catch(IOException iExc){}

hope its clear.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 Are you sure that the value you assign at line4 is not null?

  And a performance tip for you. When you initialize Strings always do it with String line = ""; and not String line = new String(); since the latter for each time you do it it creates a new String and consumes memory, while the former as many times as you do it it assigns the same meory location (so you save memory) :-). So the following:

  String line1 = new String();
  String line2 = new String();
  String line3 = new String();

  will consume 3 different memory locations while the following:

  String line1 = "";
  String line2 = "";
  String line3 = "";

  will only consume one memory location and all three instances of String (lien1, line2, line3) will point to the same.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 So what was the problem?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.