Write system call results to a text box

I am making a DOS system call that creates a file. Once this file is created it gives me a "packet created successfully" message that is written to the screen.

I am using Netbeans 5.5.1 and Swing. and I want this message to be output into a JtextArea. The system call works fine and the file is created, I just can't get the message to write to my text area.

Below is a sample of my code:

privatevoid btn_importActionPerformed(java.awt.event.ActionEvent evt){

// TODO add your handling code here:

String Rep = txt_Repname.getText();

String Work = txt_Workdir2.getText();

String VOB = txt_VOBtag.getText();

String VOBstorage = txt_VOBName2.getText();

String Replicapath = txt_Replicapath.getText();

String command = ("cmd /c multitool mkreplica -import -npreserve -nc -vreplica " + Rep +" -work " + Work +" -tag \\" + VOB + " -vob" + VOBstorage + "" + Replicapath);

StringBuffer sb =new StringBuffer();

Process p =null;

try{

p = Runtime.getRuntime().exec(command);

}catch (IOException ex){

ex.printStackTrace();

}

Scanner s =new Scanner(p.getInputStream());

while(s.hasNextLine()){

sb.append(s.nextLine()+"\n");

}

String result = sb.toString();

txt_Importresults.setText(result);

}

[1999 byte] By [yelllow4ua] at [2007-11-27 10:44:43]
# 1

> while(s.hasNextLine()) {

>sb.append(s.nextLine()+"\n");

> }

Are you sure that it's every actually exiting this block? And if it does, it's probably throwing an exception saying the stream is closed. Update your (j)textarea inside the while loop to test this theory out

tjacobs01a at 2007-7-28 20:08:32 > top of Java-index,Java Essentials,New To Java...
# 2

This works okay for me.

import java.io.IOException;

import java.util.Scanner;

public class Tester {

public static void main(String[] args) throws IOException {

StringBuffer sb = new StringBuffer();

Process p = null;

try {

p = Runtime.getRuntime().exec("HELP");

} catch (IOException ex) {

ex.printStackTrace();

}

Scanner s = new Scanner(p.getInputStream());

while(s.hasNextLine()) {

sb.append(s.nextLine());

sb.append(System.getProperty("line.separator"));

}

System.out.println(sb.toString());

}

}

Have you read the Traps article on JavaWorld?

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

_helloWorld_a at 2007-7-28 20:08:32 > top of Java-index,Java Essentials,New To Java...
# 3

That was it.....works great now;-) Thanks!

yelllow4ua at 2007-7-28 20:08:32 > top of Java-index,Java Essentials,New To Java...