Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.7k views
in Java FTP by
I downloaded your library and have figured out how to use the progress bar for any number of bytes. My question is would it be possible (in some way/shape/form to make this happen every second, returning the number of bytes?

The only way I can currently think of is if it returns every time the packet is sent (setting it to 1 would acomplish this) and then just using time to get the avg bytes/second.

Any idea's on this (since you have built the client) would be awesome.

Btw, here is my testing code:
import com.enterprisedt.net.ftp.*;
import java.io.*;

public class test
{
  public static void main(String args[])
  {
   try {
    FTPClient ftp = new FTPClient();
    ftp.setRemoteHost("ftp.ip.right.here");
    ftp.connect();
    ftp.login("user", "password");
    ftp.chdir("tmp");
    ftp.chdir("robert");
    FTPProgressMonitor blah = new monitor(); 
    ftp.setProgressMonitor(blah, 2048);
    ftp.get("mod_auto_script");
    ftp.quit();
   }
   catch(Exception e)
   {
     System.out.println(e);
   }    
  }
}

import com.enterprisedt.net.ftp.*;
import java.io.*;

public class monitor implements FTPProgressMonitor
{
  public void bytesTransferred(long bytes)
  {
    System.out.println(bytes + " bytes Transfered..");
  }
}


So what I"m thinking is changing monitor in order to grab the total bytes already transfered (which I figured was the long there) and subtracting from the previous returned bytes, comparing the time's (through private's obviously) and then taking this calculation to create a "bytes by second."

This seems like a kind of cheap way to do it though, so any eaiser way would be awesome.

Thanks in advance.

1 Answer

0 votes
by (162k points)
Sounds reasonable.

So what I"m thinking is changing monitor in order to grab the total bytes already transfered (which I figured was the long there) and subtracting from the previous returned bytes, comparing the time's (through private's obviously) and then taking this calculation to create a "bytes by second."

Categories

...