Conversion from Input Stream to Output Stream

Discussion in 'Java' started by Kashif Ur Rehman, May 17, 2007.

  1. How to convert from InputStream to OutputStream as I am using
    jdk1.4.2.

    Thanks
     
    Kashif Ur Rehman, May 17, 2007
    #1
    1. Advertising

  2. Kashif Ur Rehman

    Daniel Pitts Guest

    On May 17, 10:42 am, Kashif Ur Rehman <> wrote:
    > How to convert from InputStream to OutputStream as I am using
    > jdk1.4.2.
    >
    > Thanks


    You can't convert an input stream to an output stream. That's like
    asking how to convert a fountain to a wet-vac.

    InputStream is used to read data from, and an OutputStream is where
    you send data to. What exactly are you trying to do?
     
    Daniel Pitts, May 17, 2007
    #2
    1. Advertising

  3. Kashif Ur Rehman

    Tom Hawtin Guest

    Kashif Ur Rehman wrote:
    > How to convert from InputStream to OutputStream as I am using
    > jdk1.4.2.


    If you have a thread that is writing to an OutputStream and you want to
    read the results from an InputStream, either use Piped(In|Out)putStream,
    or buffer the whole thing in a BufferedArrayOutputStream and then use
    toByteArray followed by a new BufferedArrayInputStream.

    If you have a method of some description that requires an InputStream
    and you want to feed it through an OutputStream, either create a thread
    that copies from input to output, or do the same thing as above with
    BufferedArray(In|Out)putStream.

    Tom Hawtin
     
    Tom Hawtin, May 17, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott Connors
    Replies:
    4
    Views:
    930
    Pete Fraser
    Nov 5, 2003
  2. Krick
    Replies:
    1
    Views:
    1,465
    John C. Bollinger
    Aug 15, 2003
  3. jaivrat
    Replies:
    4
    Views:
    501
    jaivrat
    Feb 2, 2005
  4. Replies:
    2
    Views:
    444
    Larry I Smith
    May 29, 2005
  5. Replies:
    9
    Views:
    644
    Alex Buell
    Apr 27, 2006
Loading...

Share This Page