我有以下代码将 DataIntegrationV8.jar 的输出打印到 JTextArea。是否可以在同一个 JTextArea 中打印该程序引发的异常?
protected Integer doInBackground() throws Exception {
Process process;
InputStream iStream;
try {
//run the DataIntegration.jar
process = Runtime.getRuntime().exec("java -jar DataIntegrationV8.jar sample.xml");
istream = process.getInputStream();
} catch (IOException e) {
throw new IOException("Error executing DataIntegrationV8.jar");
}
//get the output of the DataIntegration.jar and put it to the
//DataIntegrationStarter.jar form
InputStreamReader isReader = new InputStreamReader(iStream);
BufferedReader bReader = new BufferedReader(isReader);
String line;
while ((line = bReader.readLine()) != null) {
jtaAbout.append(line + "\n");
}
Thread.sleep(1);
return 42;
}