I don't think your response changes my answer significantly. But here are some clarifications:
Kasi Viswan wrote:I don't know if i can use input stream for this case, i decided to go with reader as i am going to read the entire line then parse the line to string array using CSVReader.
Well, I'm pretty sure you
can still use an InputStream. You just have to figure out how to insert it into the mix of different streams you use to read the data. Some ideas:
or
Alternately, it wouldn't be hard to count characters instead of bytes. You could extend FilterReader to make a CountingReader, much like the ByteCounter shown elsewhere. Insert that into your chain of Readers, and use it to count characters read.
Kasi Viswan wrote:I know i can count the number of line read and display it to the user as nth record being processed and so on but thought would be nice to show the user a progress bar that also gives the user an idea as to how much more time it would take to complete the task and for the progress bar i need to know the number of lines in the file beforehand.
Sure. You can count lines, characters, or bytes. All are fairly easy. But for a really big file, counting lines will take some time before you can display
anything meaningful to the user. Whereas counting bytes or characters can be done right away, usually. Exception: if you're using UTF-8 with any non-European languages, it's hard to estimate the total number of characters in a file without reading the whole file. But for typical English-language files, it's easy.