Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

OutputStream  RSS feed

 
Siddiq Gadit
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a function
int send (OuputStream out);
How do I send this OutputStream 'out' to a URL.
I can get an OuputStream to the URL by doing
connection.getOutputStream();
Iam unable to comprehend as to how the URL's OutputStream
relates to the one in the function parameter.
In other words, Do I need to somehow read the OutputStream
being passed in, and then write that to the OutputStream
of the URL. If so, can someone please tell me how ?
Thanks,
Sid.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hopefully I understand your problem but.... Well we'll try to offer some help anyway.
The outputstream in the method can be any outputstream regardles of how it was created or what it was created on (a file, url, socket, string etc.) so I assume that in the send() method, something is writen to the outputstream that you pass it. To use it in your case it's simply.
OutputStream urlOut = connection.getOutputStream();
int sendCount = send(urlOut);

Now whatever send() puts onto the outputstream will get sent to the URL that you created.
I hope this helps
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!