title: StreamCorruptedException: invalid type code: AC
body: <p>My problem is when it tries to read the object the second time, it throws the exception: </p>
  
  <pre><code>java.io.StreamCorruptedException: invalid type code: AC
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1356)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
      at Client.run(BaseStaInstance.java:313)
  
  java.io.StreamCorruptedException: invalid type code: AC
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1356)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
      at Client.run(BaseStaInstance.java:313)
  </code></pre>
  
  <p>The first time I send the exact same object message; however, when I try doing the same thing the second time, it throws the error above. Do I need to re-intialize the readObject() method? I even printed out the message object that is being received by the line below and its exact the same as the first instance where it works ok. </p>
  
  <pre><code>Object buf = myInput.readObject();
  </code></pre>
  
  <p>I'm assuming there's some problem with appending, but I really have no use for appending. I just want to read a fresh line everytime.
  I'd really appreciate some help in fixing this bug. Thank you.</p>
  
  <p>==================================</p>
  
  <p>Before that one line, I'm just creating the input and output objects for the socket in the run() method. The object declaration is outside the run() method in the class:-</p>
  
  <pre><code>@Override
  public void run() {
      try {
          sleep((int) 1 * 8000);
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      try {
          //Creating input and output streams to transfer messages to the server
          myOutput = new ObjectOutputStream(skt.getOutputStream());
          myInput = new ObjectInputStream(skt.getInputStream());
          while (true) {
              buf = myInput.readObject();
          }
      } catch (UnknownHostException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      } finally {
          try {
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>You're right; I don't close the object. I'm not sure how to do that.</p>