I am using Runtime.exec() to execute some commands, capture the output of the command and process it. In my case the output is in XML format and output can be very large i.e. upto 11-15 MB for a command.
First I created a command string which contained full path to command I want to execute, command name, arguments and redirect file name. For eg
<command_path>/<command_name> <list_of_arguments> >> <redirect_file_name>
Using Runtime.exec(String) version it did not work as parser have problem giving redirect symbol as parser assumes its also an argument for command.
Then I tried another approach where I just execute the command and get the large XML output and write it myself to a file in chunks of 8K buffer. I get the Process.getInputStream() and use BufferedWriter to write it out myself.
This works but after a while I get out of memory error for my application.
I was wondering if somebody who has experience handling large output from commands using Runtime.exec on Unix and Windows can advice or help me.
My email id is xxx@xxx
Thanks in advance.
[please use the forum, not email
- thanks, Ilja]
[ August 17, 2005: Message edited by: Ilja Preuss ]