Help fixing an out of bounds excepting when merging arrays

And here's if you want to be a smart ass =P

package javaapplication3;

import java.io.; import java.util.; import java.util.Arrays;

public class listmerge {

public static void main(String[] args) throws FileNotFoundException {

    //The file we are reading from.
    File nums = new File("C:\\SortedLists.txt");

    //Open the scanner with a try/catch.
    try (Scanner numsReader = new Scanner(nums)) {

        //Create the first array for the given length.
        int[] array = new int[numsReader.nextInt()];

        //Copies the list in to the array.
        for (int counter = 0; counter < array.length; counter++) {
            array[counter] = numsReader.nextInt();
        }
        //Create the second array for the given length.
        int[] array2 = new int[numsReader.nextInt()];

        //Copies the list in to the array.
        for (int counter = 0; counter < array2.length; counter++) {
            array2[counter] = numsReader.nextInt();
        }
        //Create the needed size for the new final array.
        int[] finalArray = new int[array.length + array2.length];

        //Merges the 2 arrays together, without sorting.
        System.arraycopy(array, 0, finalArray, 0, array.length);
        System.arraycopy(array2, 0, finalArray, array.length, array2.length);

        //Sort!
        Arrays.sort(finalArray, 0, finalArray.length-1);
        System.out.println(Arrays.toString(finalArray));
        finalArray = reverse(finalArray);
        //Print out the final array.
        System.out.println(Arrays.toString(finalArray));

        //Close the stream.
        numsReader.close();
    }
}

private static int[] reverse(int[] array){
    int[] temp = new int[array.length];
    for(int x = array.length-1, y = 0; x>=0; x--, y++){
           temp[y] = array[x];
    }
    return temp;
}

}

/r/javahelp Thread Parent