public static < T , U extends T > int safeWrite ( int num , ArrayWritable < U > aw , T [ ] array ) { final int elementsToCopy = Math . min ( num , Math . min ( aw . size ( ) , array . length ) ) ; if ( elementsToCopy <= 0 ) { return 0 ; } aw . writeToArray ( 0 , array , 0 , elementsToCopy ) ; return elementsToCopy ; }
Writes a given maximum amount of data items from a container to an array . This method ensures that the array s capacity is not exceeded .