Convert a outputstream to an inputstream
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   maarten_storm
Posted On:   Wednesday, April 11, 2001 07:21 AM

How can I convert a java.io.PrintStream to a java.io.BufferedReader?

I need to print to a JTextArea, it supports only the method '.read(Reader in, Object desc)'.

Re: Convert a outputstream to an inputstream

Posted By:   Tim_Rohaly  
Posted On:   Wednesday, May 16, 2001 10:36 AM

Your question strongly suggests that you don't understand
how to use JTextArea and that you don't understand
much about the design of Swing. The read() method
is to be used only for initializing the component,
and not for keeping it up to date. All Swing components
keep their state in a data model - in the case of JTextArea
this is an implementation of Document. Modifying
the underlying data model is done through methods belonging
to the model.


The suggestion to use a piped stream is a bad one in this
context, although it will work just fine in general when piping
an output stream to an input stream.


I think you need to do some serious reading about Swing,
in particular about the Model/View/Controller pattern that
Swing uses. See the Swing FAQ for suggested references.

Re: Convert a outputstream to an inputstream

Posted By:   Michael_Wax  
Posted On:   Wednesday, April 11, 2001 03:23 PM

Used PipedInputStream and PipedOutputStream (or PipedReader and PipedWriter). You can find an explanation of how to do this at http://java.sun.com/docs/books/tutorial/essential/io/pipedstreams.htm.
About | Sitemap | Contact