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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:54:14+00:00 2026-06-06T08:54:14+00:00

I have a web application which needs to perform a file copy operation and

  • 0

I have a web application which needs to perform a file copy operation and show user a progress bar.

Currently, the copy is being done by calling cpio which cannot give progress to the Java code until after the operation has completed. While it would be possible to use Java to monitor the number of bytes written vs. number of bytes read for an estimate of the copy progress, I think there might be a simpler solution if I code the actual copy operation in Java. I would still use cpio for archiving purposes, but the actual copy would be performed by a Java class.

Most of the help I found in my searching was related to progressMonitor, which incorporates a swing component, and I’m not sure that it can do what I want. All I need is an integer/double of the progress which I can feed to my web application’s progress bar component as a % out of 100.

  • 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-06T08:54:23+00:00Added an answer on June 6, 2026 at 8:54 am

    Here is how to copy a file in java and monitor progress on the commandline:

    import java.io.*;
    
    public class FileCopyProgress {
        public static void main(String[] args) {
            System.out.println("copying file");
            File filein  = new File("test.big");
            File fileout = new File("test_out.big");
            FileInputStream  fin  = null;
            FileOutputStream fout = null;
            long length  = filein.length();
            long counter = 0;
            int r = 0;
            byte[] b = new byte[1024];
            try {
                    fin  = new FileInputStream(filein);
                    fout = new FileOutputStream(fileout);
                    while( (r = fin.read(b)) != -1) {
                            counter += r;
                            System.out.println( 1.0 * counter / length );
                            fout.write(b, 0, r);
                    }
            }
            catch(Exception e){
                    System.out.println("foo");
            }
        }
    }
    

    You would have to somehow update your progress bar instead of the System.out.println().
    I hope this helps, but maybe i did not understand your question.

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

Sidebar

Related Questions

I have a web application which basically process entries of the user when the
I currently have a Web Application which is using it's own Permissions table which
I have a web application that stores a lot of user generated files. Currently
I have an web application which logs all the activities perform by the client
i have Web Application which should use JSF 2.0 libraries included in WEB-INF/lib... but
I have web application which we deployed in a production . We have separate
I have web application of which major part is javascript. I request images from
I have a web application which provides an API in addition to the actual
I have a web application which dynamically adds javascript files based on what the
I have a web application which contains both secure (SSL) and non-secure pages. A

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.