}
public void
run()
{
QTFastStartRAF raf = null;
String name = file.getName();
int dot_pos = name.lastIndexOf('.');
String ext = dot_pos<0?"":name.substring(dot_pos+1);
try{
raf = new QTFastStartRAF( file, user_agent != null && QTFastStartRAF.isSupportedExtension( ext ));
raf.seek( offset );
byte[] buffer = new byte[max_read_chunk];
long rem = length;
long pos = offset;
while( rem > 0 ){
if ( cancelled ){
throw( new Exception( "Cancelled" ));
}else if ( channel_destroyed ){
throw( new Exception( "Destroyed" ));
}
int chunk = (int)Math.min( rem, max_read_chunk );
int len = raf.read( buffer, 0, chunk );
sendEvent( new event( new PooledByteBufferImpl( buffer, 0, len ), pos, len ));
rem -= len;
pos += len;
}
}catch( Throwable e ){
sendEvent( new event( e ));
}finally{
if ( raf != null ){
try{
raf.close();
}catch( Throwable e ){
Debug.out( e );
}