java - 为什么 Java 将目录的 logcat 路径视为过滤器表达式?
问题描述
我需要将 logcat 从 Android 设备复制到 windows pc。Logcat 命令:
adb -s deviceUDID logcat -d > C:\logcat\logcat.log
从命令行成功运行。但是,如果我从代码运行它:
public void adbCommand(adbCommands theCommand) throws IOException {
Log.info("Running ADB command : " + theCommand.get_command());
Process exec = Runtime.getRuntime().exec(theCommand.get_command());
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(exec.getInputStream()));
BufferedReader errorReader = new BufferedReader(new InputStreamReader(exec.getErrorStream()));
new Thread(() -> {
try {
String line;
while((line=bufferedReader.readLine())!=null){
Log.info(line);
}
while((line=errorReader.readLine())!=null){
Log.info("error: "+line);
}
} catch (IOException e) {
e.printStackTrace();
}
}).start();
try {
exec.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
Log.info("Done");
输出是:
adb -s deviceUDID logcat -d -s > C:\logcat\logcat.log 错误:无效的过滤器表达式 'C:\logcat\logcat.log'
任何想法这里有什么问题?谢谢!
解决方案
将打印输出与手动输入的字符串进行比较:
Running ADB command : adb -s deviceUDID logcat -d -s > C:\logcat\logcat.log
Pring to println : adb -s deviceUDID logcat -d -s > C:\logcat\logcat.log –
Manually entered: adb -s deviceUDID logcat -d > C:\logcat\logcat.log
有一个额外的 -s
推荐阅读
- bash - 将 bash shell 中执行的每个命令传递给一个变量
- javascript - 从ui中获取多个值
- python - 如何修复索引数组中最大值的错误?
- arrays - Kotlin distinct() 来自 2 维数组
- paypal - 如何在 PayPal 确认页面中显示订阅付款?
- visual-studio-code - 如何在 VSCode 中检索活动的 CustomTextEditor
- java - 使用 mockito 和 Junit5 使用参数模拟静态 void 方法
- qt - 需要有关 font.pointSize 和 font.pixelSize 的帮助
- javascript - Firebase 使用 1 个参数调用。预计没有
- excel - 处理前重新格式化 Excel 文档