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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:07:04+00:00 2026-05-13T17:07:04+00:00

I need a little help with the JProgressBar component. My program copies files from

  • 0

I need a little help with the JProgressBar component. My program copies files from one place to another using java.nio FileChannels. The actual copy method is transferFrom().

I’ve got two questions now.

  1. How to I monitor the transfer progress of FileChannels? All tutorials I’ve found use the conventional java.io InputStreams and increase the progress int while looping through the inputstream.

  2. My copy methods (the FileChannel methods) are encapsulated in a separate method that is invoked by other methods that iterate though source and destination folders and then invoke the FileChannel methods for each file.

How do I implement a ProgressBar for the complete copy mechanism?

Well I should have read the FAQ a little earlier, so I guess I have to edit my initial post instead of commenting the answers, right?

Ok this is what I’ve done so far.
Just as jambjo suggested (thanks by the way), the transferFrom() method is now looped.
BTW: Is there a preferable chunk size, or does it depend on the granularity of my progress bar just as EJP said?

Here is my code snippet:

while (position < size) {
 position += destination.transferFrom(source, position, chunkSize);
 current =  (position/size)*100;
 System.out.println(current);
}

Unfortunately the ‘current’ value stays 0 within the loop and I’ve got no idea why.
Am I missing something?

Thanks again jambjo! I really appreciate your input!
Now that the progress monitoring of a single file works, let’s address my second problem.


I’d like, no I have to, monitor progress of not only a single file, but rather a bunch of files.
My main copy methods iterates through various directories and copies appropriate files by invoking the actual transfer method.
So the copy methods don’t transfer files, they are just selecting files for the actual transfer method.

  • 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-05-13T17:07:04+00:00Added an answer on May 13, 2026 at 5:07 pm

    There is no way to monitor the progress of a single invokation of transferFrom, but since you can pass it offset and length parameters, you can implement your own loop around it and update the progress bar between suitable sized chunks of data.

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

Sidebar

Related Questions

I need a little help. I'm trying to put together a small Java program
Need a little help: I'm using jquery treeview plugin (this one: http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ ). And
I would need little help here. I'm trying to get the git respository from
I need a little help getting a tar file to download from a website.
need a little help with this one. I have a form that I am
I need a little help with updating my UI from Runnable/Handler every second. I'm
I need a little help.I'm using a ViewFlipper to change views in TabActivity but
I need a little help. I am fairly new to reflection. We're using a
I need a little help understanding something. I am using the colorbox plugin to
I need a little help for one sql query; here is my basic user

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.