title: Serialization - not working
body: <p>I create class with methods like a <a href="https://stackoverflow.com/questions/134492/how-to-serialize-an-object-into-a-string">How to serialize an object into a string</a>
  and it every say error "java.lang.ClassCastException: java.lang.String cannot be cast to Myclass"</p>
  
  <p>My codes:
  1)</p>
  
  <pre><code>import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.io.Serializable;
  
  import javax.xml.bind.DatatypeConverter;
  
  public class Serialization {
  
      public static Object fromString(String s) throws IOException,
              ClassNotFoundException {
          byte[] data = DatatypeConverter.parseBase64Binary(s);
          ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
                  data));
          Object o = ois.readObject();
          ois.close();
          return o;
      }
  
      public static String toString(Serializable o) throws IOException {
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ObjectOutputStream oos = new ObjectOutputStream(baos);
          oos.writeObject(o);
          oos.close();
          return DatatypeConverter.printBase64Binary(baos.toByteArray());
      }
  }
  </code></pre>
  
  <p>2) - calling</p>
  
  <pre><code>MyClass hl = (MyClass) Serialization.fromString(items
          .getString("data"));
  hl.load(); // this is my method from class
  </code></pre>
  
  <p>3) MyClass - Hologram</p>
  
  <pre><code>public class Hologram implements Serializable {
  
   /**
   * 
   */
  private static final long serialVersionUID = 1L;
  
  private Location loc;
  private String name;
  private String displayname;
  public ArmorStand stand;
  
  public Hologram(String name, String displayname, Location loc) {
  this.loc = loc;
  this.name = name;
  this.displayname = displayname;
  
  ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(loc,
      EntityType.ARMOR_STAND);
  
  as.setGravity(false);
  as.setCanPickupItems(false);
  as.setCustomName(displayname);
  as.setCustomNameVisible(true);
  as.setVisible(false);
  
  this.stand = as;
  
  HologramManager.holograms.put(name, this);
  
  }
  
  public void move(Location loc) {
  this.loc = loc;
  
  stand.teleport(loc);
  }
  
  public Location getLocation() {
  return this.loc;
  }
  
  public void remove() {
  stand.remove();
  HologramManager.holograms.remove(name);
  }
  
  public void removeHologram() {
  HologramManager.remove(name);
  }
  
  public void changeName(String name) {
  HologramManager.holograms.remove(this.name);
  this.name = name;
  HologramManager.holograms.put(name, this);
  }
  
  public void changeDisplayName(String displayName) {
  this.displayname = displayName;
  stand.setCustomName(displayname);
  stand.setCustomNameVisible(true);
  }
  
  public void load() {
  //todo
  }
  
  }
  </code></pre>