title: Find average of numbers in text file
body: <p>I have a text file with words and numbers and I need to write a class that creates a new file identical to the first except it shows the average.</p>
  
  <p>I just need code that identifies the integers and finds the average of them.</p>
  
  <p>The file reads like:</p>
  
  <p>blah blah 4 blah
  blah 2 3 blah 3
  blah blah blah blah
  etc...</p>
  
  <p>but on the new file the average will be on the bottom.</p>
  
  <p>My code so far:</p>
  
  <pre><code>private File inFile;
  private Scanner input;
  private File outFile;
  private PrintWriter output;
  
  public fileCloner(String inFilename, String outFilename)
  {        
      inFile = new File(inFilename);                        
      outFile = new File(outFilename);
  
      makeLinks();
      writeFiles();
      closeLinks();
  
  public void makeLinks() throws FileNotFoundException
  {          
      input = new Scanner(inFile);
      output = new PrintWriter(outFile);
  }    
  
  public void writeFiles()
  {       
      while (input.hasNext()) 
          {                     
              String line = input.nextLine();                        
              output.println(line);                    
          }
  
  
      output.println("\n");        
      output.println("The average is" + );  
  
  
  }
  
  
  public void closeLinks()
  {   
      input.close();               
      output.close();        
  }
  </code></pre>
  
  <p>Any help is appreciated, thanks in advance.</p>