title: How to populate array from .TXT file without put any duplicates in the array?
body: <p>Basicaly need to scan this text file put it in to an array but i cant put any duplicates so it has to check the array and see if the array already contain that number, i cant use array list to do that.<br /><p>
    My program puts in to an array put it put duplicates so how do i catch those duplicates to do something else with that and keep my array free of duplicates??</p>
  
  <pre><code>public static void readFromfile()throws IOException {
  
  
      int[] numbers = new int[500];
      int result, searchValue;
  
      int index = 0;
  
      // Open the file.
      File file = new File("file.txt");
      Scanner inputFile = new Scanner(file);
      int w = 0;
      for (int i=0; i&lt;numbers.length; i++) {
          if (i==0 || numbers[i] != numbers[i-1]) {
              numbers[w++]=numbers[i];
              while(inputFile.hasNextInt() &amp;&amp; index &lt; numbers.length) {
                  numbers[index] = inputFile.nextInt();
                  Arrays.sort(numbers);
                  System.out.println(numbers[index]);
                  //index++;
              }
  
          }
      }
  
      // Close the file.
      inputFile.close();
      }
  }
  </code></pre>