我正在尝试在java中记录所有应用程序的输出,由于某种原因它只捕获前两行我知道应用程序输出比这更多这是我的代码
logOut = new BufferedWriter(new FileWriter("WebAdmin.log"));
ProcessBuilder procBuild = new ProcessBuilder(
"java", "-Xmx1G", "-Xms512M", "-jar", "TekkitServer\\Tekkit.jar", "nogui", "-nojline"
);
server = procBuild.start();
inputStream = new BufferedReader(new InputStreamReader(server.getInputStream()));
errorStream = new BufferedReader(new InputStreamReader(server.getErrorStream()));
outputStream = new BufferedWriter(new OutputStreamWriter(server.getOutputStream()));
String line = "";
while(!shutdown){
while((line = inputStream.readLine()) != null){
logOut.write(line+"\r\n");
logOut.flush();
System.out.println(line);
}
System.out.println("checking error stream");
while((line = errorStream.readLine()) != null){
logOut.write(line+"\r\n");
logOut.flush();
System.out.println(line);
}
}
System.out.println("Stoped Reading");
logOut.close();
server.destroy();
我什至没有在控制台中看到“检查错误流”。