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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:15:04+00:00 2026-06-07T02:15:04+00:00

I am transferring file from client to server. I dont know the amount of

  • 0

I am transferring file from client to server. I dont know the amount of time it will take to transfer. But my UI will simple remain the same without any intimation to user. I need to keep a progress bar in such a way it should be progress till file is uploaded. How can i acheive this.

I am abit aware of this scenario in .net. but how can we do it in java?

  • 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-07T02:15:06+00:00Added an answer on June 7, 2026 at 2:15 am

    trashgod’s answer is correct for actions that are truly ‘indeterminate’. Why do you think that your file transfer fits into this category? Haven’t you ever downloaded a file on the internet with some sort of progress bar associated with it? Can you imagine not having that?

    See the example below that was provided among the answers to How do I use JProgressBar to display file copy progress?

    public OutputStream loadFile(URL remoteFile, JProgressBar progress) throws IOException
    {
        URLConnection connection = remoteFile.openConnection(); //connect to remote file
        InputStream inputStream = connection.getInputStream(); //get stream to read file
    
        int length = connection.getContentLength(); //find out how long the file is, any good webserver should provide this info
        int current = 0;
    
        progress.setMaximum(length); //we're going to get this many bytes
        progress.setValue(0); //we've gotten 0 bytes so far
    
        ByteArrayOutputStream out = new ByteArrayOutputStream(); //create our output steam to build the file here
    
        byte[] buffer = new byte[1024];
        int bytesRead = 0;
    
        while((bytesRead = inputStream.read(buffer)) != -1) //keep filling the buffer until we get to the end of the file 
        {   
            out.write(buffer, current, bytesRead); //write the buffer to the file offset = current, length = bytesRead
            current += bytesRead; //we've progressed a little so update current
            progress.setValue(current); //tell progress how far we are
        }
        inputStream.close(); //close our stream
    
        return out;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have anyone tried to transfer file from Server to Client? or Transferring XML from
I am trying to transfer a binary file from the server to the client
I have implemented a client-server transferring from Windows desktop application to iPhone App. I
I need to implement a file transferring from a web server to a SFTP
Hi I have a problem in transferring file from server to server I want
I have a File Transfer Application that sends files and folders. (Server - client)
I am making simple one on server side & one on client side application
At the moment I'm working on a quite tricky transferring from a .csv file
I am tranfering a file from one server to another using Core FTP mini-sftp-server
I'm trying to upload a backup file from my server to my Google storage

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.