hi peter :-)
this is the exact same way we use it to store generic serializable java-objects in our db.
//is closing necessary: (?)
o.close();
YES, you should always close streams. its almost done bye the runtime, but you cannot be sure.
kind regards
peter
-----Ursprüngliche Nachricht-----
Von: Peter Karich [mailto:peatha..ahoo.de]
Gesendet: Freitag, 9. März 2007 21:41
An: use..ayenne.apache.org
Betreff: Re: AW: Store BitSet
Hi, Peter Schröder!
> you may use
> http://java.sun.com/j2se/1.4.2/docs/api/java/io/ObjectOutputStream.html
> to serialize any given object. but i guess thats not what you want.
Ah thank you! with the addition of ByteArrayOutputStream it is very easy:
//writing:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(new BitSet());
oos.close();
byte array[] = baos.toByteArray();
writeProperty(BIT_SET_PROPERTY, array);
//reading:
ByteArrayInputStream bais = new
ByteArrayInputStream((byte[])readProperty(BIT_SET_PROPERTY));
ObjectInputStream o = new ObjectInputStream(bais);
BitSet date = (BitSet) o.readObject();
//is closing necessary: (?)
o.close();
Thank you again and sorry for this not-cayenne-related question,
Peter Karich.
___________________________________________________________
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
This archive was generated by hypermail 2.0.0 : Mon Mar 12 2007 - 04:27:25 EDT