Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String SFTPHOST = ""; // remote server host
- int SFTPPORT = 22;
- String SFTPUSER = "user";
- String SFTPPASS = "password";
- String SFTPWORKINGDIR = "/test";
- Session session = null;
- Channel channel = null;
- ChannelSftp channelSftp = null;
- Vector files = null;
- session = jsch.getSession(SFTPUSER, SFTPHOST, SFTPPORT);
- session.setPassword(SFTPPASS);
- java.util.Properties config = new java.util.Properties();
- config.put("StrictHostKeyChecking", "no");
- session.setConfig(config);
- session.connect();
- channel = session.openChannel("sftp");
- channel.connect();
- channelSftp = (ChannelSftp) channel;
- channelSftp.cd(SFTPWORKINGDIR);
- files = channelSftp.ls("*");
- for (ChannelSftp.LsEntry file : docFiles) {
- if (file.getAttrs().isDir()){
- continue;
- }else{
- // It is reading upto 1022 files only??
- inputStream = channelSftp.get(SFTPWORKINGDIR+"/"+fileName);
- // some further code
- }
- }
Add Comment
Please, Sign In to add comment