1 package net.sf.openrocket.util;
3 import java.lang.reflect.Array;
5 public class ArrayUtils {
8 * Implementation of java.util.Arrays.copyOfRange
10 * Since Froyo does not include this function it must be implemented here.
17 public static <T> T[] copyOfRange( T[] original, int start, int end ) {
19 if ( original == null ) {
20 throw new NullPointerException();
23 if ( start < 0 || start > original.length ) {
24 throw new ArrayIndexOutOfBoundsException();
28 throw new IllegalArgumentException();
31 T[] result = (T[]) Array.newInstance( original.getClass().getComponentType(), end-start );
34 int stop = original.length < end ? original.length : end;
35 for ( int i = start; i < stop; i ++ ) {
36 if ( i < original.length ) {
37 result[index] = original[i];