// //First Create a JSch session // System.out.println("Creating session."); JSch jsch = new JSch(); session = null; channel = null; // ChannelSftp c = null;
// //Now connect and SFTP to the SFTP Server // try { //Create a session sending through our username and password session = jsch.getSession(ftpUserName, ftpHost, ftpPort); System.out.println("Session created."); session.setPassword(ftpPassword); //Security.addProvider(new com.sun.crypto.provider.SunJCE());
// //Setup Strict HostKeyChecking to no so we dont get the //unknown host key exception // java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(); System.out.println("Session connected.");
// //Open the SFTP channel // System.out.println("Opening Channel."); channel = session.openChannel("sftp"); channel.connect(); c = (ChannelSftp)channel; } catch (Exception e) { System.err.println("Unable to connect to FTP server. "+e.toString()); throw e; }
// //Change to the remote directory
// System.out.println("Changing to FTP remote dir: " + ftpRemoteDirectory); c.cd(ftpRemoteDirectory); String s = c.pwd().toString(); System.out.println(s);
/*Picking all the files from one location*/
File folder = new File("D:\\Test_final"); File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) {
File f = new File(foldernames.get(list).toString()); System.out.println(foldernames.get(list).toString()); // System.out.println("The number of folder is"+ f.listFiles()); files_in_folder=f.listFiles(); for(int all_files=0; all_files<=files_in_folder.length-1;all_files++ ){ allfilenames.add(files_in_folder[all_files].getAbsolutePath()); }
// c.quit(); }
/* After collecting all the files in a array list,uploading the files to the sever*/
//Here I could able to upload only the last two files in the array list
In the above program.Only the last two file in the array list is getting posted to server.
I could not able to do a bulk transfer of all the file.
PLease help me in this regard.
View Answers
Related Pages:
Java SFTP - Java Beginners Java SFTP Hi I want to perform SFTP through Jsch package. I could able to sftp one file but I could not able to sftp multiple files.
PFB my... to SFTP files.
*
*/
public class SftpClient_Mars {
Files f =new Files
Deployer
is an Eclipse plug-in to deploy files in
remote servers, using SSH. It uses SFtp.... It's written in Java and released
under the Lesser General Public License (LGPL
Eclipse plugin-Network
to configure application's launch Java VM parameters such as security policy... to and from SFTP sites.
configuration of SFTP sites can be made on a workbench level
Java FTP Library Java FTP Library 
The Java Ftp Library
Let's imagine a situation where we want to write a pure Java application that must download files from
java
java hi im new to java plz suggest me how to master java....saifjunaid@gmail.com
java java How to set java Policy for applet using jdk 6
java
java dear,
i want a field for date picker using java/java script
java
java why methods in java raise exceptions
Have a look at the following link:
Java Exceptions
java java code to search the nodes how to write the java code to search the nodes using routers
java java online telephone directory i need coding for online telephone directory..by using java....pls help me
java
java how to edit text document by using java
then how to edit starting and ending of text document by using java
java
java different between java & core java
print("code sample
java java pattern code for a given words java pattern code for a given words pattern
java
java how can use sleep in java
which book learn of java language
java
java create java program for delete and update the details,without using database, just a normal java program
java
java different between java & core java
print("code sample
java
java how to prepare the java
Hi Friend,
If you want to learn how to install java, creating and running a java program then go through the following links:
http://www.roseindia.net/java/beginners/index.shtml
http