The Artima Developer Community
Sponsored Link

Java Answers Forum
How to Convert OutputStream() into String

1 reply on 1 page. Most recent reply: Aug 24, 2002 3:52 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Ajay

Posts: 1
Nickname: ajaye
Registered: Aug, 2002

How to Convert OutputStream() into String Posted: Aug 23, 2002 10:09 PM
Reply to this message Reply
Advertisement
I am developing an Editor in which I want to read the content of the outputstream Here is th e code:
com= "javac " +(filename);
Process p= null;
try
{
Runtime r = Runtime.getRuntime();
p = r.exec(com);
inputstream stdrr=p.getErrorStream();
......
}

As I am reading the contents of the input stream ..I also like to read the content of OutputStream in a textarea.So how to read the content of OuputStream.
Thaking you
Ajay


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: How to Convert OutputStream() into String Posted: Aug 24, 2002 3:52 PM
Reply to this message Reply
You could try something like this:

inputstream stdrr=p.getErrorStream();
if (results = null) results = new JTextArea(40,60);

try{
InputStreamReader isr = new InputStreamReader(inputstream);
BufferedReader br = new BufferedReader(isr);
String lineread = "";
while ((lineread = bufferedreader.readLine()) != null){
results.append(lineread + "\n");
}
bufferedreader.close();
inputstreamreader.close();
}catch(IOException ioe){
System.err.println("IOException: " + ioe.getMessage());
}

Flat View: This topic has 1 reply on 1 page
Topic: I now program works but problem with display Previous Topic   Next Topic Topic: Servlet Pooling

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use