I tried to simplify the problem as much as possible.
The easiest way to add/remove elements to an Array for your case would be to use an ArrayList object. Read through the comments and run the project.
The first list of integers below are the original input's of the file.
The second list contains the array's printed statements. These answers might not be where you expect them to be indexed but I'm sure this will get you on the right path :)
10 2 5 1 7 4 9 3 6 8
[10, 2, 5, 1, 7, 4, 9, 3, 6, 8] 3 1 7 5 2 8 package cs1410; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; import javax.swing.JFileChooser; public class ArrayReader { public static void main(String[] args) throws FileNotFoundException { // Creates an array list ArrayList<Integer> answer = new ArrayList<Integer>(); // Reads in information JFileChooser chooser = new JFileChooser(); if (JFileChooser.APPROVE_OPTION != chooser.showOpenDialog(null)) { return; } File file = chooser.getSelectedFile(); // Scan chosen document Scanner s = new Scanner(file); int count = 0; // Scans each line and places the value into the array list while (s.hasNextLine()) { int input = s.nextInt(); answer.add(input); } // Kaboom System.out.println(answer); System.out.println(answer.indexOf(1)); System.out.println(answer.indexOf(2)); System.out.println(answer.indexOf(3)); System.out.println(answer.indexOf(4)); System.out.println(answer.indexOf(5)); System.out.println(answer.indexOf(6)); } }