Skip to Main Content

Java Programming

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!

slow ftp in java using:org.apache.commons.net.ftp

807589Nov 11 2008 — edited Nov 11 2008
I am FTPing using the library "org.apache.commons.net.ftp" but its taking a lot of time, can anyone tell me that is there anything wrong with my code that is decreasing the transfer rate OR any other method for FTP in java?

My Code is :

localInputStream = new BufferedInputStream(new FileInputStream(filepath));
OutputStream remoteOutputStream = null;
remoteOutputStream = ftp.storeFileStream(fileName);
BufferedOutputStream bufferedRemoteOutputStream = new BufferedOutputStream(remoteOutputStream );

// Actual transfer of the data file
byte[] buf = null; // output buffer
int bufLen = ftpbuffer * 1024;
buf = new byte[bufLen];
int len = 0;
int r = 0;
int br = 0;
while ((len = localInputStream.read(buf, 0, bufLen)) != -1)
{
r++;
bufferedRemoteOutputStream.write(buf, 0, len);
br = br + len;
}
finally {
if (ftp.completePendingCommand())
{...
....
...
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 9 2008
Added on Nov 11 2008
5 comments
4,972 views