objectCloner - bufferedReader exception
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ivn_Tcakov
Posted On:   Tuesday, April 2, 2002 11:52 AM

Hello, there is some problems with making a deep copy (cloning) of a certain Vector that contains some Class. This is the method I am using to make the deep copy: static public Object deepCopy(Object oldObj) throws Exception { ObjectOutputStream oos = null; ObjectInputStream ois = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); // A oos = new ObjectOutputStream(bos); // B // serialize and pass the object oos.writeObject(oldObj); // C oos.flush(); // D ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray()); // E ois = new ObjectInputStream(bin); // F    More>>

Hello,
there is some problems with making a deep copy (cloning) of a certain Vector that contains some Class.
This is the method I am using to make the deep copy:

			
static public Object deepCopy(Object oldObj) throws Exception
{
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
try
{
ByteArrayOutputStream bos =
new ByteArrayOutputStream(); // A
oos = new ObjectOutputStream(bos); // B
// serialize and pass the object
oos.writeObject(oldObj); // C
oos.flush(); // D
ByteArrayInputStream bin =
new ByteArrayInputStream(bos.toByteArray()); // E
ois = new ObjectInputStream(bin); // F
// return the new object
return ois.readObject(); // G
}
catch(Exception e)
{
System.out.println("Exception in ObjectCloner = " + e);
throw(e);
}
finally
{
oos.close();
ois.close();
}
}

This is the exception it gives me when I try to copy one class I have:
java.io.invalidClassException: java.io.BufferedReaderMissing no-arg constructor for class

I don't really understand this. The Buffered reader Interface doesn't have a no-arg constructor, so I can't really create one.
Actually, the Object that I am cloning (copying) doesn't even contain any BufferedReader Classes. Or as much as I can see, it doesn't.
Would anyone know what would be the cause to this exception?
Thanks
Ivan    <<Less
About | Sitemap | Contact