question: @ Override public byte [ ] decode ( byte [ ] data ) throws Exception { if ( data [ 0 ] == 0 && data [ 1 ] == 0 && data [ 2 ] == 0 ) { return data ; } int bufSize = 512000 ; FastByteArrayOutputStream bos = null ; boolean failed = true ; final int orgSize = data . length ; if ( data != null ) { while ( failed ) { final Inflater inf = new Inflater ( ) ; inf . setInput ( data ) ; final int size = data . length ; bos = new FastByteArrayOutputStream ( size ) ; if ( size < bufSize ) { bufSize = size ; } final byte [ ] buf = new byte [ bufSize ] ; int count ; try { while ( ! inf . finished ( ) ) { count = inf . inflate ( buf ) ; bos . write ( buf , 0 , count ) ; if ( inf . getRemaining ( ) == 0 ) { break ; } } failed = false ; } catch ( final Exception ee ) { LogWriter . writeLog ( "Exception in Flate " + ee ) ; failed = true ; hasError = true ; if ( data . length == orgSize && data . length > 10000 ) { failed = false ; } else if ( data . length > 10 ) { final byte [ ] newData = new byte [ data . length - 1 ] ; System . arraycopy ( data , 0 , newData , 0 , data . length - 1 ) ; data = newData ; } else { failed = false ; } } } data = bos . toByteArray ( ) ; return applyPredictor ( predictor , data , colors , bitsPerComponent , columns ) ; } return data ; }
target:  flate decode - use a byte array stream to decompress data in memory