0

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

2
Contributors
4
Replies
22
Views
2 Years
Discussion Span
Last Post by manalibhadula
0

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());
                }
            }
0
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.
Be sure to adhere to our posting rules.