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
You need to use the [code] tags so that the code you posted displays properly (see button above reply text field).What does "blows up" mean?Is there an exception being thrown? If so, post the stack trace.
jbisha at 2007-7-12 10:02:50 > top of Java-index,Java Essentials,Java Programming...
# 2
It says there is a null pointer exception. But I am getting a feature back. It does not like when I put the feature back into VectorFeature[ ].....this is a class.
seadazea at 2007-7-12 10:02:50 > top of Java-index,Java Essentials,Java Programming...
# 3

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.

java_2006a at 2007-7-12 10:02:50 > top of Java-index,Java Essentials,Java Programming...
# 4

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);

seadazea at 2007-7-12 10:02:50 > top of Java-index,Java Essentials,Java Programming...
# 5
>VectorFeature isn't an array"VectorFeature array" means array of VectorFeature objects !!>public VectorFeature(VectorFeature must implement java.io.Serializable interface.In addition, every VectorFeature attribute should be serializable.
java_2006a at 2007-7-12 10:02:50 > top of Java-index,Java Essentials,Java Programming...