images, writing over url connection

From: (
Date: 05/24/04

Date: Mon, 24 May 2004 12:57:48 +0200

Hello, pretty new to java so bear with me.

I am trying to write an image over an HttpURLConnection.

I have an example of how to write text but I am having real problems trying
to write an image, just can't get my head around it.

I have succeeded in writing to the local HD using ImageIO:
//start image output
 FileOutputStream fo = new FileOutputStream("myImg.jpg");
 BufferedOutputStream bo = new BufferedOutputStream(fo);
 ImageIO.write(destination, "jpeg", bo);
//end image output

This works a treat. I understand how to set up an url connection and then
write text to it:

//start text to url
URL url = new URL( "" );
HttpURLConnection urlcon = (HttpURLConnection) url.openConnection( );



PrintWriter pout = new PrintWriter( new
OutputStreamWriter(urlcon.getOutputStream( ), "8859_1"), true );

pout.print( formData );//form data collected from app
pout.flush( );
// end text to url

What I am having a problem with is this bit:
 PrintWriter pout = new PrintWriter( new
OutputStreamWriter(urlcon.getOutputStream( ), "8859_1"), true );

Where I want to put in my buffered output stream, and then use that with
ImageIO, I just can't see where I am supposed to start.... or have I missed
the boat entirely

Thanks for taking the time to read this post.

Thanks for your time

--------------- - dynamic websites - fine art - photographic supplies