title: Simpler way to write a java output to both console and text file?
body: <p>So im a pretty big noob at java and I have a exam coming up and have been practicing all week. My progress has been slow but steady. One exercise I am doing requires me to print the output of an array calculation to a console AND create a file <code>temperature.txt</code> with the console output and same formatting.</p>
  
  <p>I've figured out how to be able to do one or the other but i'm having trouble doing both (remember slow and steady learner). Is there a simpler beginners method to keep in mind?</p>
  
  <pre><code>import java.io.FileWriter;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.text.DecimalFormat;
  
  public class Temperature {
  
      public static void main(String[] args) throws IOException{ 
          double[] temps = {100, 98, 80.5, 90.2, 99.4, 89.1};
          MaxMin(temps);
  
      }
  
      public static void MaxMin(double[]temps) throws IOException{
          FileWriter fwriter = new FileWriter("Temperatures.txt", true);
          PrintWriter outputfile = new PrintWriter(fwriter);
          double min= Double.MAX_VALUE;
          double max= Double.MIN_VALUE;
          double sum = 0;
  
          DecimalFormat formatter = new DecimalFormat("0.0");
  
          for(int i = 0;i&lt;temps.length;i++){
              sum += temps[i];
              if(temps[i] &gt; max){
                  max = temps[i];
              }
              if(temps[i]&lt; min){
                  min = temps[i];
              }
          }
  
          double avg = sum / temps.length;
          outputfile.println("Average Temp: " + formatter.format(avg));
          outputfile.println("Maximum Temp: " + formatter.format(max));
          outputfile.println("Minimum Temp: " + formatter.format(min));
          outputfile.close();
      }
  }
  </code></pre>
  
  <p>What I have above prints the text but nothing on the console.</p>
  
  <p>edit: would it be acceptable to just add 3 System.out.println statements at the end to fulfill both requirements? like this:</p>
  
  <pre><code>System.out.println("Average Temp: " + formatter.format(avg));
  System.out.println("Maximum Temp: " + formatter.format(max));
  System.out.println("Minimum Temp: " + formatter.format(min));
  
  outputfile.println("Average Temp: " + formatter.format(avg));
  outputfile.println("Maximum Temp: " + formatter.format(max));
  outputfile.println("Minimum Temp: " + formatter.format(min));
  outputfile.close();
  </code></pre>