Link to home
Start Free TrialLog in
Avatar of NextOne
NextOne

asked on

How to convert Java Serialisable Object to Byte Array

Hi,
does anybody know how to convert a Java Object like Image Object into a byte[] to do stuff with it after....

For exemple if i create serialisable object and i want to store them in database in byte []

help !
Avatar of Nevyn
Nevyn

The is a couple of classes in the io package called ByteArrayOutputStream and ByteArrayInputStream. Wrap these with any OutputStream you desire and you have your byte[].
you need
java.awt.image.PixelGrabber

ASKER CERTIFIED SOLUTION
Avatar of Jim Cakalic
Jim Cakalic
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NextOne

ASKER

I prefere the Jim cakalic answer that is full of explenation and very interesting... I gonna try

thanks to everybody
Avatar of NextOne

ASKER

thanks, i gonna try
>> how to convert a Java Object like Image Object into a byte[]

well - java.awt.Image is not Serializable :)
Avatar of NextOne

ASKER

Well yes, but i found a solution, i read directly the file...
But i use a Sybase DataBase and I've a stream problem,
I can only read 32768 bytes...