title: Sum of Numbers program that prints the total sum of all integers stored on a file
body: <p>I'm still pretty new to files in java, and I have not yet grasp the understanding of using loops to process file though it may be a simple question to most I'm having difficulties getting the total sum of integer values stored on a text file try as i must. Any help is apricated!</p>
  <p>Here is the question I'm working on:</p>
  <p>Assume that a file containing a series of integers is named number.dat and exists on the computers disk. Design a program that calculates the average of all the numbers stored in the file.</p>
  <p>Here is code I currently have:</p>
  <pre><code>    import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.Scanner;
  
  public class Sum_of_Numbers {
      public static void main(String[] args) throws FileNotFoundException {
          File CalFile = new File(&quot;C:\\Users\\Tyrese\\JAVA 2\\Chapter 10\\number.dat.txt&quot;);
          Scanner bot = new Scanner(CalFile);
  
          int sum = 0;
          while (bot.hasNextLine()) {
              sum += 1;
              bot.nextLine();
          }
  
          System.out.println(&quot;The number in the file sum up to:&quot; + sum);
      }
  }
  </code></pre>
  <p>I'm unable to get the correct output as intended. Please feel free to modify and change the file path if necessary or the code to aid me in completing the question I'm baffled on, again any help is appreciated.</p>