private void doSingleTransfer() throws IOException, JSchException { StringBuilder sb = new StringBuilder("scp -t "); if (getPreserveLastModified()) { sb.append("-p "); } if (getCompressed()) { sb.append("-C "); } sb.append(remotePath); final String cmd = sb.toString(); final Channel channel = openExecChannel(cmd); try { final OutputStream out = channel.getOutputStream(); final InputStream in = channel.getInputStream(); channel.connect(); waitForAck(in); sendFileToRemote(localFile, in, out); } finally { if (channel != null) { channel.disconnect(); } } }
if (getPreserveLastModified()) { String command = "T" + (localFile.lastModified() / 1000) + " 0"; command += " " + (localFile.lastModified() / 1000) + " 0\n";
private void doMultipleTransfer() throws IOException, JSchException { StringBuilder sb = new StringBuilder("scp -r -d -t "); if (getPreserveLastModified()) { sb.append("-p "); } if (getCompressed()) { sb.append("-C "); } sb.append(remotePath); final Channel channel = openExecChannel(sb.toString()); try { final OutputStream out = channel.getOutputStream(); final InputStream in = channel.getInputStream(); channel.connect(); waitForAck(in); for (Directory current : directoryList) { sendDirectory(current, in, out); } } finally { if (channel != null) { channel.disconnect(); } } }