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
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
help you how ?
by writing the code ? no. we're not coders-for-hire.
what have you tried so far ?
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());
}
}
and what is the point you are having trouble with ?
Added this below line and it is working fine:-
channel = session.openChannel("sftp");
channel.connect();
channelSftp = (ChannelSftp) channel;
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.