Search code examples
javaswingjprogressbar

JProgressBar working according to application load in swing


I want to develop small project for file copy application in java swing. I want to show progress bar for that, means how much percent data is been copy.. so can any body tell me idea how to develop it


Solution

  • Sure thing. Here is an idea: When you copy files use InputStream and read a standard size of bytes, say 1024 bytes, and copy it to the new file. Each time you read the file, your progress is

    (1024 bytes * NumberOfReads)/SizeOfFileInBytes