程序如下:
为什么程序只有proc.getErrorStream()才有输出,而proc.getInputStream()却没有输出?而imp命令确实是执行成功了?
Runtime run = Runtime.getRuntime();
String exeString = "imp sys/sys@orcl file=c:/20120309.dmp fromuser=user1 touser=user1";
System.out.println("导入语句为:" + exeString);
try {
Process proc = Runtime.getRuntime().exec(exeString);
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
System.out.println( " <ERROR> ");
while ( (line = br.readLine()) != null)
System.out.println(line);
System.out.println( " </ERROR> ");
int exitVal = proc.waitFor();
System.out.println( "Process exitValue: " + exitVal);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
--转自
该贴由koei123转至本版2015-6-2 9:10:25