This I found as a workaround for a ClassCastException I had problems with, when I did not want to mess with Classloaders. I can't take credit for it, as I did not write, think, implement, or in any other way contribute to this. I found it here, by John Davison!
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( baos );
oos.writeObject( c2 );
ByteArrayInputStream bais = new ByteArrayInputStream(
baos.toByteArray() );
ObjectInputStream ois = new ObjectInputStream( bais );
FooBar newC2 = (FooBar) ois.readObject();
Prenumerera på:
Inlägg (Atom)
