On Tue, 15 Nov 2005 18:33:29 +0000 (UTC), "KevinRobinson"
<k.s.robinson@btinternet.com> wrote, quoted or indirectly quoted
someone who said :
>Can anyone please supply me with a coding solution to uploading /
>downloading images to a mysql database.Or can anyone recommend
Where is your image to start? Let's say in a flat file on disk. Just
load it in one fell swoop into a byte[]. See
http://mindprod.com/applets/fileio.html
for the code.
Now you can feed it as a BLOB to your database.
Now you fetch it back as a blob and turn in back into a byte[].
Now you want to render it. You could convert your byte[] to a
byteArrayInputStream. again see the file i/o amanuensis for how.
Then use ImageIO to read the bytes to create a image. See
http://mindprod.com/jgloss/imageio.html
BufferedImage image = ImageIO.read ( new ByteArrayInputStream (
rawImageBytes ) );
Alternatively you could use:
Toolkit.getDefaultToolkit().createImage( rawByteArray , start, length
);

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.