I want to create a progressBar for an FTP download. The server where I am downloading the file has all of its directories and files hidden. I want to display the progress of the download. Is there any way I can get the file size? Here is my current code:
FTPclient = new FTPClient();
FTPclient.setListHiddenFiles(true);
FTPclient.connect(hostPart);
FTPclient.login(userName, passWord);
FTPclient.setFileType(FTP.BINARY_FILE_TYPE);
InputStream instream = FTPclient.retrieveFileStream(pathExcludingHostIncludingFirstSlash);
int l;
byte[] tmp = new byte[2048];
int updateCounter = 0;
int bytesDownloaded = 0;
while ((l = instream.read(tmp)) != -1) {
fos.write(tmp, 0, l);
bytesDownloaded+=2048;
updateCounter++;
if(updateCounter==3){
kilobytesDownloaded=(bytesDownloaded / 1024);
publishProgress((String[])null);
updateCounter=0;
}