import java.util.Scanner;
import java.lang.ArrayIndexOutOfBoundsException;
import java.io.File;
import java.io.FileNotFoundException;

class Mar20 {
	public static void main(String[] args) {

		Scanner kb = new Scanner(System.in);

		System.out.print("Enter index: ");
		int index = kb.nextInt();	
		
		int[] arr = new int[5];

		try {
			arr[index] = 7;
		} 
		catch(ArrayIndexOutOfBoundsException e) {
			System.out.println("Error: out of bounds.");
		}

		// populate array with data from file

		Scanner fin = null;

		try {
			fin = new Scanner(new File("data.txt"));
		}
		catch(FileNotFoundException e) {
			System.out.println("File not found");
			System.exit(0);
		}

		System.out.println("Reading from file...");

		for(int i = 0; i < arr.length; i++) {
			arr[i] = fin.nextInt();
		}

		// print array

		for(int elm : arr) {
			System.out.print(elm + " ");
		}
		System.out.println();

	}
}
