Execute ADB command from Java program

前端 未结 4 1830
死守一世寂寞
死守一世寂寞 2020-12-09 06:38

The program I\'m working on uses ADB (Android Debug Bridge) to send files to my phone:

for (String s : files)
    String cmd = \"adb -s 0123456789ABCDEF push         


        
4条回答
  •  孤街浪徒
    2020-12-09 07:17

    I finally got it working:

    ProcessBuilder pb = new ProcessBuilder("adb", "-s", "0123456789ABCDEF", "push", inputfile, outputfile);
    Process pc = pb.start();
    pc.waitFor();
    System.out.println("Done");
    

    I don't know what problems ProcessBuilder has with spaces in a string, but finally, it's working...

提交回复
热议问题