I'm trying to create my own ProgressFileInputStream
It has Listeners that get informed whenever a read is done with the number of bytes read.

I've extended FileInputStream and rewritten all the read methods and the skip method. After each read i inform the listeners of the number of bytes read.

Unfortunately when i add up all the bytes received by the listener it equals 362. When i do fileObject.length() i get 1121. Where have the other 759 bytes gone!!!

I know the filObject.length() is right as windows reports the size as 1,121 bytes.

This is my code in the ProgressFileInputStream class...

Code:
    public int read() throws IOException
    {
        int value = super.read();
        readNBytes(1);
        return value;
    }
	
    public int read(byte[] b) throws IOException
    {
        int value = super.read(b);
        readNBytes(value);
        return value;
    }
	
    public int read(byte[] b, int off, int len) throws IOException
    {
        int value = super.read(b, off, len);
        readNBytes(value);
        return value;
    }
	
    public long skip(long n) throws IOException
    {
        long value = super.skip(n);
        readNBytes(value);
        return value;
    }
and my readNBytes just does this...

Code:
    private void readNBytes(long n)
    {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(int i=0; i<theFileInputProgressListeners.size(); i++)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((FileInputProgressListener)theFileInputProgressListeners.get(i)).bytesLoaded(n);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
oh and finally my FileInputProgressListener interface is...

Code:
public abstract interface FileInputProgressListener
{
&nbsp;&nbsp;&nbsp;&nbsp;public void bytesLoaded(long number);
}
Any idea what i'm doing wrong?