File Handling - Problem in counting number of records
Hi I have count the total number of records (Lines) in a file
Number of Records = File Size / Record size
Here Record size is fixed
For eg., 4 Records with each record of size 10, then the expected file size is 40. But in my case file size is getting varied in like instaed 40 bytes it says 41 bytes. Because of this I'm facing a problem in counting number of records
Could any one solve this?
Thanks in Advance,
Bala
> Hi I have count the total number of records (Lines)
> in a file
>
> Number of Records = File Size / Record size
>
> Here Record size is fixed
>
> For eg., 4 Records with each record of size 10, then
> the expected file size is 40. But in my case file
> size is getting varied in like instaed 40 bytes it
> says 41 bytes. Because of this I'm facing a problem
> in counting number of records
>
> Could any one solve this?
>
> Thanks in Advance,
> Bala
Message was edited by:
snic.snac
Coding is pretty simple
File inFile = new File(file);
fileSize = inFile.length();
int recSize = 464;
recCount = fileSize / recSize;
Problem here file size is getting varied
For eg., 4 Records with each record of size 464then
Expected file size = 464 * 4 = 1856
But actual file size which we receive is 1858 (Even in windows file property it shows the same size)
Since size is increased than expected value the record count is calculating wrongly