This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 5811
    
    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: 5811
    
    7

Declare a ByteArrayOutputStream and wrap it in a PrintStream. Once done, use toByteArray() to get the output and create a String from that.
 
wood burning stoves
 
subject: How to capture Ant output to a string variable
 
Similar Threads
Where to run the saved ant script of Deployable plug-ins and fragments
How to import a web project in eclipse?
how to execute ant build.xml programatically ?
Get som sort of return value from ANT
Running ANT Programmatically Through Java