Confused with PrintWriter, OutputStream and OutputStreamWriter.

Discussion in 'Java' started by CamT, Mar 16, 2005.

  1. CamT

    CamT Guest

    Hello

    Rather confused with PrintWriter, OutputStream and OutputStreamWriter.

    Not sure how to pass osw to pw.

    PrintWriter pw=getAgentOutput();
    RichTextItem body = (RichTextItem) docRT.getFirstItem("RTItem");
    OutputStreamWriter osw = new OutputStreamWriter( new
    RichTextOutputStream(body, true, true) );

    Want print the contents of osw rich is a RichText to pw so as to do
    println.

    Or is there a better way to parse the richtext?

    Many thanks
     
    CamT, Mar 16, 2005
    #1
    1. Advertising

  2. CamT

    Oscar kind Guest

    CamT <> wrote:
    > Rather confused with PrintWriter, OutputStream and OutputStreamWriter.
    >
    > Not sure how to pass osw to pw.
    >
    > PrintWriter pw=getAgentOutput();
    > RichTextItem body = (RichTextItem) docRT.getFirstItem("RTItem");
    > OutputStreamWriter osw = new OutputStreamWriter( new
    > RichTextOutputStream(body, true, true) );
    >
    > Want print the contents of osw rich is a RichText to pw so as to do
    > println.
    >
    > Or is there a better way to parse the richtext?


    It seems that you want the RichTextItem refered to by "body" to be written
    to the PrintWriter refered to by "pw". If this is correct, read on.

    To receive a stream of data representing the RichTextItem, you need a
    RichTextInputStream (I'm assuming it exists). Then, read the contents of
    that stream through an InputStreamReader to get characters.

    Then, you can write the characters you receive from the InputStreamReader
    into the PrintWriter (or any other Writer for that matter).


    --
    Oscar Kind http://home.hccnet.nl/okind/
    Software Developer for contact information, see website

    PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
     
    Oscar kind, Mar 16, 2005
    #2
    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. Lars Willich
    Replies:
    0
    Views:
    601
    Lars Willich
    Jan 28, 2005
  2. yzzzzz

    Writer and PrintWriter

    yzzzzz, Mar 25, 2005, in forum: Java
    Replies:
    2
    Views:
    4,350
    yzzzzz
    Mar 25, 2005
  3. Roedy Green
    Replies:
    6
    Views:
    1,708
    Chris Uppal
    Jan 5, 2006
  4. Replies:
    2
    Views:
    3,606
  5. Jochen Brenzlinger
    Replies:
    7
    Views:
    5,578
    Roedy Green
    Sep 15, 2011
Loading...

Share This Page