public static < T > T [ ] arrayCopyOf ( T [ ] array , int newSize ) { @ SuppressWarnings ( "unchecked" ) T [ ] newArr = ( T [ ] ) Array . newInstance ( array . getClass ( ) . getComponentType ( ) , newSize ) ; System . arraycopy ( array , 0 , newArr , 0 , Math . min ( newSize , newArr . length ) ) ; return newArr ; }
Utility method similar to Java 1 . 6 Arrays . copyOf used instead of that method to stick to Java 1 . 5 only API .