请检查以下片段我在哪里尝试使用runtime exec命令生成进程,并在等待该进程使用p.waifor()方法终止之后,但生成的java进程即使已经终止也不会被终止完成了它的执行。执行将在此行停止p.waitFor()。
StringBuilder sb = new StringBuilder();
sb.append( "java -jar " + path + " " );
if( arguments != null && !arguments.isEmpty() )
{
for( int i = 0; i < arguments.size(); i++ )
{
sb.append( arguments.get( i ) + " " );
}
}
Process p = Runtime.getRuntime().exec( sb.toString() );
BufferedReader in = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
String line;
StringBuilder stringBuilder = new StringBuilder();
while( (line = in.readLine()) != null )
{
stringBuilder.append( line );
}
int statusCode = p.waitFor();
in.close();