how can I read generic-type object with object stream?
I declared a class like this
class Storage<K extedns Key, Dextends Data>implements Serializable{
}
class Keyimplements Serializable{
}
interface Dataextends Serializable{
}
and I used ObjectOutputStream to save.
Storage<MyKey, MyData> storage =new Storage<MyKey, MyData>();
ObjectOutputStream out =new ObjectOutputStream(new FileOutputStream(new File("file")));
out.writeObject(storage);
after save code, I tryed to write loading code like
ObjectInputStream in =new ObjectInputStream(new FileInputStream(new File("file")));
Storage<MyKey, MyData> storage = (Storage<MyKey, MyData>)in.readObject();
but, it occurs a casting error. How can I downcast my Object object to Storage<MyKey, MyData> object?

