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 8066969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:09:04+00:00 2026-06-05T12:09:04+00:00

Hello i need a status bar for FTP download. I would like to get

  • 0

Hello i need a status bar for FTP download.
I would like to get a float <=1 with the progess. This is my code:

                float status=0;
                FTPFile[] files = ftp.listFiles(REMOTEFILE);
                if (files == null || files.length == 0) {
                    throw new FileNotFoundException();
                }
                long size = files[0].getSize();
                InputStream inputStream = ftp.retrieveFileStream(REMOTEFILE);
                byte buf[] = new byte[1024];
                int len;
                int download=0;
                while ((len = inputStream.read(buf)) > 0){
                    out.write(buf, 0, len);
                    download+=1024;
                    status=(float)download/size; // here it set the progress
                }
                out.close();

My trouble is that at the end status is more than 1 and I think is over the buffer size of 1024 (in case of not full buffer at the end). Maybe because downloaded bytes are more than how much files[0].getSize() gives to me?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 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-06-05T12:09:05+00:00Added an answer on June 5, 2026 at 12:09 pm

    You add 1024 bytes to download no matter how many bytes are actually read. You already have a ref to the number of bytes read; len – use this instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I need to do something like this: UPDATE tbl SET pozn=CONCAT(pozn, '+attach_str+') WHERE
Hello i am in desperate need of help on this i have an image
ok so i have have this {status:0,id:7aceb216d02ecdca7ceffadcadea8950-1,hypotheses:[{utterance:hello how are you,confidence:0.96311796}]} and at the moment
Hello I'm writing a little project in c++ where I would like to have
Hello I need to generate a report which would include both data and a
Hello I need to get only the methods declared in a class, and not
Hello i need to create a progressView when i load data from my webservice.
Hello I need to sort cgridview data table by id DESC how can me
Hello I need to have multiple language support of my django admin application.I can
hello i need to do the following: move a node from jstree to another

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.