title: readUTF() returns error after writeObject()
body: <p>I'm setting up a new server-client system. Here from the client, an object will be sent to the server. And after receiving the object the server will send a string to the client. </p>
  
  <p>Here the server reads the object successfully. But when the clients want to read the string sent by the server it throws EOFException.</p>
  
  <p>client-side</p>
  
  <pre><code>public static void main(String args[]) throws IOException, EOFException {
      try (Socket socket = new Socket("localhost", 1254)) {
  
          OutputStream outputStream = socket.getOutputStream();
          InputStream s1In;
          DataInputStream dis;
          try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream)) {
              s1In = socket.getInputStream();
              dis = new DataInputStream(s1In);
              Frame frame = new Frame();
              frame.setData("test");
              objectOutputStream.writeObject(frame);
  
          String st = "";
          while(dis.available() &gt;0){
              st = dis.readUTF();
          }
          System.out.println(st);
          }
          dis.close();
          s1In.close();
      }
  }
  </code></pre>
  
  <p>server-side</p>
  
  <pre><code>public static void main(String args[]) throws IOException, ClassNotFoundException {
      ServerSocket s = new ServerSocket(1254);
      Socket socket = s.accept(); 
      OutputStream outputStream = socket.getOutputStream();
  
      ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
  
  
      //input stream
      InputStream inputStream = socket.getInputStream();
      DataInputStream dataInputStream = new DataInputStream(inputStream);
      ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
  
      Frame frame = new Frame();
      frame = (Frame) objectInputStream.readObject();
      String data = frame.getData();
      System.out.println(data);
      // Send a string!
      DataOutputStream dos = new DataOutputStream (outputStream);
      dos.writeUTF("Received");
      dos.close();
      objectOutputStream.close();
      outputStream.close();
      objectInputStream.close();
      inputStream.close();
      socket.close();
  }
  </code></pre>
  
  <p>error at client side</p>
  
  <pre><code>Exception in thread "main" java.io.EOFException
  at java.io.DataInputStream.readFully(DataInputStream.java:197)
  at java.io.DataInputStream.readUTF(DataInputStream.java:609)
  at java.io.DataInputStream.readUTF(DataInputStream.java:564)
  at computernetworklab.Client.main(Client.java:38)
  /home/shahad/.cache/netbeans/8.2/executor-snippets/run.xml:53: Java 
  returned: 1
  BUILD FAILED (total time: 0 seconds)
  </code></pre>