title: Java Serialization Pains (java.io.StreamCorruptedException)
body: <p>I'm trying to Serialize an object to a Byte array, for storage in a String. I cannot for the life of me figure out where I'm going wrong here.</p>
  
  <pre><code>String store = null;
  
  // Writing
  try {
      String hi = "Hi there world!";
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(out);
      oos.writeObject(hi);
      oos.close();
  
      store = out.toString("UTF-8");
  } catch(Exception e) {
      System.out.println(e);
  }
  
  // Reading
  try {
      ByteArrayInputStream in = new ByteArrayInputStream(store.getBytes("UTF-8"));
      ObjectInputStream ois = new ObjectInputStream(in);
  
      String data = (String) ois.readObject();
  } catch(Exception e) {
      System.out.println(e);
  }
  </code></pre>
  
  <p>I keep getting <code>java.io.StreamCorruptedException</code> and I don't know why :(</p>