为什么Java将目录的logcat路径视为过滤器表达式?
我需要将logcat从Android设备复制到windows pc。 Logcat命令:为什么Java将目录的logcat路径视为过滤器表达式?,java,android,adb,Java,Android,Adb,我需要将logcat从Android设备复制到windows pc。 Logcat命令: adb-s设备UDID logcat-d>C:\logcat\logcat.log 从命令行成功运行。但是,如果我从代码运行它: public void adbCommand(adbCommands theCommand) throws IOException { Log.info("Running ADB command : " + theCommand.get_command());
adb-s设备UDID 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设备UDID 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使其工作的唯一方法是在adb命令之前添加“cmd/c”:
- cmd/c adb-s设备udid logcat-d>c:\logcat\logcat.txt