title: Java Read / Write To File - BufferedReader BufferedWriter
body: <p>This is a code snippet but basically what I want to do is read from a file named 'listings.txt' and write to a file named 'overview.txt'. I want to take the information out of 'listings.txt' and put them into 'overview.txt' as is (I will figure out the rest later).</p>
  
  <p>The file 'overview.txt' is created and appears to loop through the file 'listings.txt' and write to 'overview.txt'. However, once I open the file 'overview.txt' it is empty. <br/> Could someone go through a quick glance at my code and spot something erroneous?</p>
  
  <pre><code>package yesOverview;
  
  import java.io.BufferedReader;
  import java.io.*;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.PrintWriter;
  import java.util.Scanner;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  
  public class yesOverview {
  
      public static void main(String[] args) {
          Scanner input = new Scanner(System.in);
          String strInput = "foo.bar";
          System.out.print("Please enter the listings file (the full path to the file): ");
          strInput = input.next();
  
          //This makes sure that the inputed file is listings.txt as required for KET1 task 2
          while (strInput.contains("listings.txt") == false) {
              System.out.print("Incorrect file. Please enter listings file(the full path to the file): ");
              strInput = input.next();
          }
  
          infos(strInput);
          input.close();
      }
  
      public static void infos(String strInput) {
          Scanner input2 = new Scanner(System.in);
          System.out.print("Please enter the overview.txt file (the full path to the file): ");
          String strInput2 = "foo.bar";
          strInput2 = input2.next();
  
          //This also makes sure that the overview.txt file is provided. 
          while (strInput2.contains("overview.txt") == false) {
              System.out.print("Incorrect file. Please enter overview file(the full path to the file): ");
              strInput2 = input2.next();
          }
  
          //Creates the file f then places it in the specified directory.
          File f = new File(strInput2);
  
          try {
              //Creates a printerwriter out that writes to the output file. 
              PrintWriter out = new PrintWriter(strInput2);
          } catch (FileNotFoundException ex) {
              Logger.getLogger(KETTask2Overview.class.getName()).log(Level.SEVERE, null, ex);
          }
  
          //String that holds the value of the next line. 
          String inputLine = "";
  
          //Creates the Buffered file reader / writer.  
          try {
              BufferedReader in = new BufferedReader(new FileReader(strInput));
              FileWriter fstream = new FileWriter(strInput2);
              BufferedWriter out = new BufferedWriter(fstream);
              while (in.readLine() != null) {
                  out.write(in.read());
              }
              in.close();
          } catch (IOException e) {
              System.err.println("Error: " + e.getMessage());
          }
  
      }
  }
  </code></pre>