ADB PULL命令

时间:2018-06-26 13:32:59

标签: java android adb

我正在尝试使用adb从MAC PC处理设备中的文件。

我手机中的一个文件夹中有一个空格,所以我环顾四周,尝试使用转义符\并使用引号如下所示

import java.io.*;
public class TestModule {
public static void main(String[] args) throws IOException,InterruptedException {
String line = "null";
String cmd = "adb pull /storage/sdcard1/Android/data/files/test\\ Information/ /Users/sbc/Desktop";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
while ((line=buf.readLine())!=null) {
System.out.println(line);
}
}
}

我在终端中运行了相同的命令,我可以访问该文件,但是通过java,它给了我远程对象不存在的错误。

非常感谢您的帮助

1 个答案:

答案 0 :(得分:1)

我找到了解决问题的方法,在下面发布了代码,

import java.io.*;
public class TestModule {

public static void main(String[] args) throws IOException,InterruptedException {

String line = "null";
String cmd = "adb pull /storage/sdcard1/Android/data/files /Users/sbc/Desktop";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
while ((line=buf.readLine())!=null) {
System.out.println(line);
}
}
}

我访问了它的父文件夹,而不是使用空格访问该文件夹 / storage / sdcard1 / Android / data / files / test \信息/ <-当前带空格的文件夹 / storage / sdcard1 / Android / data / files <-父文件夹。

现在adb下载“父文件夹”的所有内容