Win a copy of Terraform in Action this week in the Cloud forum!

Vladimir Baranovich

Greenhorn
+ Follow
since Aug 17, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vladimir Baranovich

Thanks for your post, I figured out a way to do it although its far from elegant. I read each line of the file into a string and the call myString.getBytes() to decode the string into a byte array. Then I can just keep a running tally of the byte array size. Also I had to add one to the value for each line because the newline character isn't part of the string but it is a part of the filesize (took me a good 20 mins to figure out what was going on with that one). Well, about all I can say is that it works.
16 years ago
Hello all,

I'm writing a program that needs to parse large text files and place the contents into a StringBuffer(so the contents can be manipulated). I would like to provide a progress bar for users, so they can know the status of the parsing. In order to make the progress bar work, I need to keep track of the "percentage done". I have used the myFile.length() method to get the filesize in bytes but I have yet to discover a way to keep track of how many bytes have been read so far. Is there a simpler way to do this? Much thanks in advance.

-VB
16 years ago