Methods Summary |
---|
public synchronized void | cleanup()
if ( mInputStream != null )
{
mInputStream.close();
mInputStream = null;
}
if ( mDeleteWhenDone )
{
getFile().delete();
}
|
public final long | getLength()
return( mTotalSize );
|
private final long | getRemaining()
return( mTotalSize - mReadSoFar );
|
public boolean | isDone()
return( mReadSoFar == mTotalSize );
|
public synchronized byte[] | read(int requestSize)
if ( isDone() )
{
throw new IllegalArgumentException( "operation has been completed" );
}
final long remaining = getRemaining();
byte[] bytes = null;
if ( remaining != 0 )
{
final long actual = remaining < requestSize ? remaining : requestSize;
bytes = new byte[ (int)actual ];
final int numRead = mInputStream.read( bytes );
if ( numRead != bytes.length )
{
throw new IOException();
}
mReadSoFar += numRead;
if ( isDone() )
{
cleanup();
}
accessed();
}
return( bytes );
|