Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to send multiple files in parallel using ftp with single connection

843790Jan 13 2007 — edited Jan 13 2007
Hi.

i have written code for file upload manager using ftp..

it perfectly working with sequence file uploading in single connection..

And i tried to upload multiple files with parallel processing in a single connection.... but it is not working properly.. i also used thread concept
but single file only transfered and connection refused...

my code here...
//////////////////// main class //////////////////////////////////////////
ftp.connect();

ftp.login();

String [] archivos = new  String[100];
					    	File dir = new File("C:\\Files Uploading\\");
							archivos = dir.list();
							for (int s=0; s<archivos.length;s++)
							{
	//Start Data Transfer Here
	new DataTransfer(archivos[s]).start();
							Thread.sleep(1000);
							}
 
/////////////////////// thread class ////////////////////////////////
class DataTransfer extends Thread
{
      String FileName="";
      String LocalPath="",RemotePath="";
       public DataTransfer(String fname)
        {
	FileName = fname;
	LocalPath = "C:\\Files Uploading\\" + FileName;
	RemotePath = FileName;
	System.out.println(LocalPath);		
        }
        public void run()
        {
                    System.out.println("DataTransfer Started");
	/File Transfer Here
	try 
                     {
	      FileInputStream input = new FileInputStream(LocalPath);
			
                           Ftp_Client.storeFile(RemotePath,input);

	System.out.println("Successfully sent : " + RemotePath);
            
	}
	catch (Exception exc) 
	{
		System.out.println(exc.getMessage());
	}
		System.out.println("DataTransfer Ended");
	}
	}
otherwise tell me any other alternate way
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 10 2007
Added on Jan 13 2007
1 comment
357 views