protected static byte [ ] getData ( byte [ ] data , int size ) { if ( data == null ) { return NO_DATA ; } if ( data . length <= size ) { return data ; } byte [ ] newData = new byte [ size ] ; System . arraycopy ( data , 0 , newData , 0 , size ) ; return newData ; }
If the given byte array is less than or equal to given size it is simply returned . Otherwise a new array is allocated and the data is copied .