i.reset();
    public void write ( long length, long offset, ByteBuffer src )	throws IOException {	if ( length < 0 )	    throw new IllegalArgumentException ( "length<0" );	if ( offset < 0 )	    throw new IllegalArgumentException ( "offset<0" );	//ChainPosition p = new ChainPosition ( offset );	ChainPosition p = position;	p.setPosition ( offset );	int clsize = p.getSize();	int clidx  = p.getIndex();	//int last;	//int cluster = 0;		//ChainIterator i = listIterator ( 0 );	ChainIterator i = iterator;	int cluster = i.getCluster ( clidx );	int last    = i.nextIndex();	//System.out.println ( "head=" + head + " clidx=" + clidx + " cluster=" + cluster + " last=" + last );		/*	for ( last = 0; last < clidx; last++ )	    if ( i.hasNext() )		cluster = i.next();	    else		break;	*/		try {	    if ( last != clidx ) {		int m = clidx - last;				long lst = offset + src.remaining() - last * clsize;				int n = (int)( lst / clsize );		if ( ( lst % clsize ) != 0 )		    n++;				last = allocateTail ( n, m, p.getOffset() );				if ( cluster != 0 ) {		    fat.set ( cluster, last );		    ((ChainIterator)i).appendChain ( last );		}		else {		    setStartCluster ( last );		    i.reset();		    //i = listIterator ( clidx );		}				/*		 * here length is used to decide		 * if we have to zero the data		 * inside the last cluster tail		 */		int ofs = (int)( length % clsize );				if ( ofs != 0 )		    fat.clearCluster ( cluster, ofs, clsize );	    }	}	finally {	    fat.flush();	}	for ( int l = src.remaining(), sz = p.getPartial(), ofs = p.getOffset(), size;	      l > 0;	      l -= size, sz = clsize, ofs = 0 ) {	    	    if ( !i.hasNext() ) {		int n = l / clsize;		if ( ( l % clsize ) != 0 )		    n++;		try {		    last = allocateTail ( n );		    if ( cluster != 0 ) {			fat.set ( cluster, last );			((ChainIterator)i).appendChain ( last );		    }		    else {			setStartCluster ( last );			i.reset();			//i = listIterator ( 0 );		    }		}		finally {		    fat.flush();		}	    }	    cluster = i.next();	    	    size = Math.min ( sz, l );	    if ( dolog )		mylog ( "write " + size + " bytes to cluster " + cluster +			" at offset " + ofs );	    int limit = src.limit();	    	    try {		src.limit ( src.position() + size );		fat.writeCluster ( cluster, ofs, src );	    }	    finally {		src.limit ( limit );	    }	}    }