Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.6k views
in Java FTP by (220 points)
hi,how to use bytestransferred to calculate directory,could someone give me a sample

4 Answers

0 votes
by (162k points)
What do you mean by 'calculate directory'?
0 votes
by (220 points)
What do you mean by 'calculate directory'?


public class CustomFTPMonitor implements FTPProgressMonitor {

private long filesize = 0;
private double percentage = 0;

public CustomFTPMonitor(long size) {
filesize = size;
}
@Override
public void bytesTransferred(long bytes) {
if ((int)percentage == 100) {
percentage = 0;
}
percentage = ((double) bytes / (double) filesize) * 100;
Ftp.bar.setValue((int)percentage);
}

}
long size = getSize(new File("C:\A"));
UpDirMonitor monitor = new UpDirMonitor(size);
ftpClient.setProgressMonitor(monitor, 1024);


here is my code,"C:\A" is a directory, which some files in, bytes in "bytesTransferred(long bytes)" calculate the separate files.
0 votes
by (162k points)
Still not sure what you mean.

bytesTransferred is fired every x bytes (roughly) during file transfers to let you know about transfer progress (upload or download)
0 votes
by (220 points)
thanks very much.I have fix my problem.

Categories

...