使用rsync的两个android设备之间的rsync文件

时间:2014-03-27 07:27:57

标签: android rsync

  try {
        Process process = Runtime.getRuntime().exec("/system/xbin/su -c sh");
        DataOutputStream os = new DataOutputStream(process.getOutputStream());


        os.writeBytes("/system/xbin/rsync -avzru  /data/shareData/ 192.168.84.111:/data/shareData/");
        String output=new String();



        os.flush();
 } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Log.i("rsync",""+e.getMessage());
 }

但不提供任何日志输出,也不是rsync成功。你能给我一些建议吗?

1 个答案:

答案 0 :(得分:0)

我已经解决了

public static void startRsync() {


    Thread thread = new Thread() {
        @Override
        public void run() {
            try {

                    Process process = Runtime.getRuntime().exec("su -c sh");
                    OutputStream os = process.getOutputStream();

                    writeLine( os, "/system/xbin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf");
                    os.flush();
                    //process.waitFor();


            }
            catch ( IOException e ) {
                e.printStackTrace();
            }

// catch(InterruptedException e){ // e.printStackTrace(); //}             }         };         thread.start();

    // sleep to give some time to statusRsync to detect process
            try{
              Thread.currentThread().sleep(2000);//sleep for 2000 ms
            }
            catch(InterruptedException e){
                e.printStackTrace();
            }

}