Can anyone help me how to pick all the files(many files) of some particular extention(.csv) and transferring it to remote server using Jsch channel.

Please help.

Regards

Here is the code i tried

Inline Code Example Here

        File folder = new File("Pathofthefolder");

            JSch jsch = new JSch();
            session = jsch.getSession(sftpUser, sftpHost, sftpPort);
            session.setPassword(sftpPaswd);
            java.util.Properties config = new java.util.Properties();
            config.put("StrictHostKeyChecking", "no");
            session.setConfig(config);
            session.connect();
    channelSftp.cd(pathOfRemoteserver);
            for (File file : listOfFiles) {
                if (file.isFile()) {
                      InputStream inputStream = new FileInputStream(file);
                       File f = new File(file.getName());
                        channelSftp.put(inputStream, pathOfRemoteserver+f.getName());
                }
            }
Added this below line and it is working fine:-




                channel = session.openChannel("sftp");
                channel.connect();
                channelSftp = (ChannelSftp) channel;
This question has already been answered. Start a new discussion instead.