Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Passing DOS output to a text frame...

I have the following code in an application class that has a text window:

public void format_textCommand( Frame fr )
{

JavaParser parser;

try {
parser = new JavaParser( new java.io.FileInputStream( fr.getTitle() ) );
} catch (java.io.FileNotFoundException e) {
System.err.println("Java Parser Version 1.1:  File " + fr.getTitle() + " not found.");
return;
}
try {
Node root = parser.CompilationUnit();
parser = null;
System.err.println("Java Parser Version 1.1:  Java program parsed " + "successfully.");
theChoice.setText( "" );
theChoice.setText( root.accept( new PrettyPrinter() ) );
} catch (ParseException e) {
System.err.println("Java Parser Version 1.1:  Encountered errors " + "during parse." + e);
}
}

My question is:

How do I pass root.accept( new PrettyPrinter() ), which sends output to a DOS window, to my text window (text window object is theChoice.setText( something ), for example).

Thank you.
0
loyaliser
Asked:
loyaliser
1 Solution
 
kaleemazizCommented:
You can't get the output going to the OutputStream (or PrintStream) System.out.
PrettyPrinter() method is probably written by you, or by a third party. If source code for PrettyPrinter() is not available, there is not much you can do about it; unless you write something like that yourself. If you have written it yourself, then you can do somethings that I can help. I have a strong feeling that PrettyPrinter is not a class you have written. Let me know if you have the source code of PrettyPrinter. I can help.
Regards.

                                                     Kaleem.

0
 
ashishagarwalCommented:
You can use setIn() and setOut() methods of the java.lang.System class to redirect the Input/Output streams to teh streams of your choice..

this should do what is reqiured by you..

best of luck!
ashish
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now