title: How to deal with scanner exception
body: <p>Basically I am taking a string input that represents a file.  That file can contain integers, doubles or random strings.  I am trying to iterate through the file adding all the integers and then taking the average of all of them.  The issue I'm stuck on is when I get something other than an integer.  I don't know how I am supposed to catch and deal with the error and then iterate onto the next part of the file.  I can't use if statements and I'm thoroughly stuck.  </p>
  
  <pre><code> String storeVariables = null;
    FileReader fileReader;
    BufferedReader bufferedReader;
    Scanner scanner = null;
    int total = 0;
    int itterate = 0;
  
  
    try{
        fileReader = new FileReader(filename);
        bufferedReader = new BufferedReader(fileReader);
        scanner = new Scanner(bufferedReader);
  
        while(scanner.hasNextInt()){
            total += scanner.nextInt();
  
            itterate++;
        }
  
    }
   catch(Exception e){
  
  
   }       
  
    return total/itterate;
  </code></pre>
  
  <p>}</p>