ObjectOuputStream can not get object back as read
I have code that reads a shape file and then takes the features and writes them out one feature at a time using an ObjectOutputStream. I read the features back in aright but I need to return them to a VectorFeature[]. I can not get that part to work.
(VectorFeature is an imported class)
private static VectorFeature feature;
private static VectorFeature[] features;
:
for (int i = 0; i < length; i++)
{
feature = features;
:
oos.writeObject(feature);
}this works
My problem is when i get it back'
obj = in.readObject();
feature = (VectorFeature)obj; (THIS RETURNS THE FEATURE)
When I try to put VectorFeature feature back into VectorFeature[] features
features[x] = feature;
it blows up. would appreciate any help.
[829 byte] By [
seadazea] at [2007-11-27 4:49:42]

1-
>for (int i = 0; i < length; i++)
>{
>feature = features;
>:
>oos.writeObject(feature);
>}this works
for (int i = 0; i < length; i++)
{
feature = features[i];//CHANGE HERE
:
oos.writeObject(feature);
}//this works====> How do you know that it works ?
2- the class VectorFeature is it serializable ? (See http://java.sun.com/j2se/1.4.2/docs/api/java/io/ObjectOutputStream.html)
3 -Please, post the code that re-construct the VectorFeature array.
VectorFeature isn't an array. and feature = features[ i ] is how I have it. I wrote a program to see if it could get the feature back for the written file and it worked. I can see my attributes etc.
[public VectorFeature(
long oop,
FeatureAttribute[] attributes,
Face[] faces,
BoundingBox boundingBox,
java.lang.String[] symbols,
java.lang.String[] _relationships
)
The following does not work either:
features[x] = new VectorFeature(feature.getOOP(),feature.getAttributes(), feature.faces,feature.getBoundingBox(),feature.symbols, feature.relationships);