问题描述
这似乎很简单
我正在使用.FormulaR1C1 = "=if(countif(c5,RC5)>1,"""",1)"
我尝试过
Runtime.getRuntime().exec(commandString);
我尝试了不使用String commandString = "logcat -v raw --pid=" + PID);
Runtime.getRuntime().exec(commandString);
的情况,也尝试过(并且需要)使用-v raw
使用多个PID。
似乎没有任何作用。我的|
一无所获。如果我不对PID进行过滤,则可以正常工作,但会打印出所有击中logcat的内容,这不是很有用。
我想念什么?
这是重要部分的整个块。
new BufferedReader(new InputStreamReader(p.getInputStream()));
解决方法
这应该有助于您将输出重定向到InputStream
(可以将其包装在BufferedReader
中):
String[] argv =
new String[] { "logcat","-v","raw","--pid=" + pid };
Process process =
new ProcessBuilder(argv)
.inheritIO()
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.start();
try (InputStream in = process.getInputStream()) {
// Consume InputStream
int status = process.waitFor();
if (status != 0) {
throw new IOException(argv + " returned exit status " + status);
}
}