Esempio n. 1
0
 @Test(groups = "spring")
 public void testDelete() throws SftpException {
   final Iterable<?> iterable = sftpChannel.ls(".");
   for (Object object : iterable) {
     com.jcraft.jsch.ChannelSftp.LsEntry entry = (LsEntry) object;
     System.out.println(entry.getFilename());
   }
   // assert sftpChannel.lstat("to_delete") == null;
   sftpChannel.put(new ByteArrayInputStream("Hello World!".getBytes()), "to_delete");
   assert sftpChannel.lstat("to_delete") != null;
   sftpChannel.rm("to_delete"); // Will throw exception if fails
 }
Esempio n. 2
0
 private void setLastModified(File localFile) throws JSchException {
   SftpATTRS fileAttributes = null;
   String remotePath = null;
   ChannelSftp channel = openSftpChannel();
   channel.connect();
   try {
     fileAttributes = channel.lstat(remoteDir(remoteFile) + localFile.getName());
   } catch (SftpException e) {
     throw new JSchException("failed to stat remote file", e);
   }
   FileUtils.getFileUtils()
       .setFileLastModified(localFile, ((long) fileAttributes.getMTime()) * 1000);
 }
Esempio n. 3
0
 @Test(groups = "spring")
 public void testCanMoveObjectsInFolders() throws SftpException {
   sftpChannel.rename(TestDataCreator.TO_MOVE_FILE_NAME, "toloc");
   sftpChannel.lstat("toloc");
 }