Skip to Content
Former Member
May 05, 2005 at 01:32 PM

Java object as IResource content


Hi everyone,

I'm stuck. Again. I'm trying to write an object to an

IResource. What i'd like to do is delete the IResource

and then recreate one with the new object as content.

I then want to read this object back in as an object at

some later point. What i have so far for the writing is:

IResource aResource = aResourceFactory.getResource(financeRID, rContext);

ICollection ic = (ICollection) aResourceFactory.getResource(baseDirectory, rContext);
IContent content = (IContent) null;
ic.createResource(FINANCE_DATA_FILE, null, content, true);

financeRID is the RID of the file i want to create. I use .delete() to get delete the file and then i use createResource to create it again. Now, i'm not sure how to create the IPropertyMap, so i just pass null and

ignore any error as i don't really need a property map.

Now the object i'm trying to write into this resource

is called FinanceDataType.

How can i write this into the file?

Also for reading it back out again i was thinking of


IContent ic = aResource.getContent();
ObjectInputStream s = new ObjectInputStream(ic.getInputStream());
FinanceDataType dfd = (FinanceDataType) s.readObject();
return dfd;

Will that work??

Thanks a tone! I'm really clueless...