Hi
I am trying to serialise an object to a file. It seems to be working e.g. it creates a file with lots of funny stuff inside but when I call it second time it throws an exception... Any ideas why would this happen ??
this is my code:
...
else if(source == saveBtn)
{
try
{
FileOutputStream fos = new FileOutputStream ("myobjects.txt"
;
ObjectOutputStream out = new ObjectOutputStream(fos);
out.writeObject(myCanvas.drawingItems);
out.close();
}
catch(IOException ex)
{
ex.printStackTrace();
}
}
...
and myCanvas.drawingItems is a Vector of objects...
I am trying to serialise an object to a file. It seems to be working e.g. it creates a file with lots of funny stuff inside but when I call it second time it throws an exception... Any ideas why would this happen ??
this is my code:
...
else if(source == saveBtn)
{
try
{
FileOutputStream fos = new FileOutputStream ("myobjects.txt"
ObjectOutputStream out = new ObjectOutputStream(fos);
out.writeObject(myCanvas.drawingItems);
out.close();
}
catch(IOException ex)
{
ex.printStackTrace();
}
}
...
and myCanvas.drawingItems is a Vector of objects...