等待进程方法 class 不 return

wait for method of process class doesn't return

我的代码中有 Process Class,当我尝试从 inputbuffer 和 waitfor process class 方法读取大量数据时,它无法读取 inputbufferreader 数据从不 return 任何东西

只需将您的代码替换为以下代码即可。
必须关闭您的 InputStream 连接。

 Process p = Runtime.getRuntime().exec(command, null, new File(workingDirectory));
// send input vi stdin
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
writer.write("\n>>>>>>>>>>");
writer.write(inputJsonString);
writer.write("<<<<<<<<<<\n");
writer.flush();

try{ 
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
for (;;)
{
    String line = reader.readLine();
    if (line == null)
    {
        break;
    }
    // System.out.println(line);
    outputString += line + "\n";
}
 p.getOutputStream().close();
 p.getInputStream().close();
}
catch(Exception e)
{
   e.printStackTrace();
}
if (JniSettings.isLinux())
{
    p.waitFor();
}
else
{
    // System.out.println("ExecJniApp: windows wait for");
}
// exit code of command and log error detail
// exit status = 0 -> Success
exitStatus = p.exitValue();
if (exitStatus != 0)
{
    System.out.println("ExecJniApp: inputJsonString: " + inputJsonString);
    System.out.println("ExecJniApp: outputString:\n" + outputString);
    throw new Exception("Exit status other than zero :- " + exitStatus + "\noutput: ");
}