Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1004111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:04:57+00:00 2026-05-16T08:04:57+00:00

I want to create a progressBar for an FTP download. The server where I

  • 0

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;
                }
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:04:59+00:00Added an answer on May 16, 2026 at 8:04 am

    There’s no way to do this reliably across all FTP services.

    The FTP protocol does not provide a way to get file sizes, so you would need to resort to requesting a directory listing and unpicking the (server specific) text that you get back. Furthermore, there is no guarantee that directory listing will be enabled, or that you will have permission to list the directory.

    Having said this, some FTP libraries can be configured to attempt to get a file size. For example, with the Apache FTPClient library you can (try to) use the listFiles(String) method and look at the resulting FTPFile object.

    EDIT

    @Kevin Brock mentions the FTP SIZE command as a possibility.

    • This is command was first defined in RFC 3659 in 2007. A lot of deployed FTP server software is much older than that.
    • SIZE is an optional command; i.e. even RFC 3659 compliant servers are not required to support it.
    • Even if SIZE is supported by a server, the current Apache FTPClient APIs do not include a method for getting the size of a file (apart from via listFiles). Of course, this may change in the future.
    • The ftp4j FTPClient class apparently does implement SIZE and make it available via its fileSize(...) method.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making an Android app where the user can download files from a FTP-server.
In my PHP web site, i want to create a file uploading progress bar.
I want to create a Circluar Determinate ProgressBar, the kind which shows the Progress
I want a progressbar to be visible until a download is finished. In order
Hello i did my notification of download file from web. Code below. I want
want to create listview with 2 component in every row 1st progressbar and 2nd
I want to download images and show the progress with a gtk.ProgressBar() . For
All, I want to crate an rich looking, custom progress bar for blackberry touch
i want create multiple search where statement $where_search is a multiple condition from post
I want create wordpress website into which I want create user management... That means

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.