public static byte [ ] getByteArray ( int size ) { byte [ ] [ ] pool = ( byte [ ] [ ] ) __pools . get ( ) ; boolean full = true ; for ( int i = pool . length ; i -- > 0 ; ) { if ( pool [ i ] != null && pool [ i ] . length == size ) { byte [ ] b = pool [ i ] ; pool [ i ] = null ; return b ; } else full = false ; } if ( full ) for ( int i = pool . length ; i -- > 0 ; ) pool [ i ] = null ; return new byte [ size ] ; }
Get a byte array from the pool of known size .