public void copyFile(Session session, String sourceFile, String destinationFile) {
    ChannelExec channel = (ChannelExec) session.openChannel("exec");
    channel.setCommand("cp " + sourceFile + " " + destinationFile);
    channel.connect();
    while(channel.isConnected()) {
        Thread.sleep(20);
    }
    int status = channel.getExitStatus();
    if(status != 0)
      throw new CopyException("copy failed, exit status is " + status);
}

 

 

 

相关文章:

  • 2022-01-10
  • 2022-12-23
  • 2021-11-23
  • 2020-04-13
  • 2022-02-09
  • 2022-01-13
  • 2021-11-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
相关资源
相似解决方案