if( length == 0 )
{
//if the length is zero then don't bother trying to decode
//some filters don't work when attempting to decode
//with a zero length stream. See zlib_error_01.pdf
unFilteredStream = new RandomAccessFileOutputStream( file );
done = true;
}
else
{
//ok this is a simple hack, sometimes we read a couple extra
//bytes that shouldn't be there, so we encounter an error we will just
//try again with one less byte.
for( int tryCount=0; !done && tryCount<5; tryCount++ )
{
try
{
input = new BufferedInputStream(
new RandomAccessFileInputStream( file, position, length ), BUFFER_SIZE );
unFilteredStream = new RandomAccessFileOutputStream( file );
filter.decode( input, unFilteredStream, this );
done = true;
}
catch( IOException io )
{