Guest User

Untitled

a guest
Dec 6th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. String SFTPHOST = ""; // remote server host
  2. int SFTPPORT = 22;
  3. String SFTPUSER = "user";
  4. String SFTPPASS = "password";
  5. String SFTPWORKINGDIR = "/test";
  6.  
  7. Session session = null;
  8. Channel channel = null;
  9. ChannelSftp channelSftp = null;
  10. Vector files = null;
  11.  
  12. session = jsch.getSession(SFTPUSER, SFTPHOST, SFTPPORT);
  13. session.setPassword(SFTPPASS);
  14. java.util.Properties config = new java.util.Properties();
  15. config.put("StrictHostKeyChecking", "no");
  16.  
  17. session.setConfig(config);
  18. session.connect();
  19.  
  20. channel = session.openChannel("sftp");
  21. channel.connect();
  22. channelSftp = (ChannelSftp) channel;
  23. channelSftp.cd(SFTPWORKINGDIR);
  24. files = channelSftp.ls("*");
  25.  
  26. for (ChannelSftp.LsEntry file : docFiles) {
  27.  
  28. if (file.getAttrs().isDir()){
  29. continue;
  30. }else{
  31. // It is reading upto 1022 files only??
  32. inputStream = channelSftp.get(SFTPWORKINGDIR+"/"+fileName);
  33. // some further code
  34. }
  35. }
Add Comment
Please, Sign In to add comment