aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes How to capture Ant output to a string variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How to capture Ant output to a string variable" Watch "How to capture Ant output to a string variable" New topic
Author

How to capture Ant output to a string variable

sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
Hi ,


I am working on ANT.my requirement is to display Ant output on HTML/Jsp page.

normally i am using Ant project to execute the build file.

here is the code-my program runs and shows ant build results/errors in the console,but i want them to be stored on a string and then use that in jsp page.



help me

Thanks
Srinivas
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

Did you try replacing the System.out and System.err in lines 5 and 6 with a StringWriter?


JBoss In Action
sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
lines 5 and 6 accept only PrintStream object.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

Declare a ByteArrayOutputStream and wrap it in a PrintStream. Once done, use toByteArray() to get the output and create a String from that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to capture Ant output to a string variable