title: Add Timestamp to file JAVA
body: <p>In the console, in eclipse, The current timestamp pops up, and I can type next to it whatever I'd like to be put into the file.</p>
  
  <p>How do I get that timestamp to print in the file as well!?!? </p>
  
  <pre><code>    import java.io.BufferedWriter;
      import java.io.File;
      import java.io.FileWriter;
      import java.io.IOException;
      import java.util.Scanner;
      import java.sql.Timestamp;
      import java.util.Date;
      public class bufferedwriter {    
      public static void main(String[] args) {
  
          Scanner myScanner = new Scanner(System.in);
          String lineToPrint = "";
          String fileName = "/Users/josephbosco/fileName.txt";
  
          do{
              java.util.Date date= new java.util.Date();
              System.out.print(new Timestamp(date.getTime()));
  
               lineToPrint = myScanner.nextLine();                 
              printToFile (fileName, lineToPrint);                
  
          } while (!lineToPrint.equalsIgnoreCase("q") );          
  
      }
  
      public static void printToFile (String myfileName, String message) {        
  
          try {
              File outfile = new File(myfileName);
  
              //if file doesn't exist, then create it
  
              if (!outfile.exists()) {
                  System.out.println("No file exists...writing a new file");
                  outfile.createNewFile();
  
              }
              FileWriter fw = new FileWriter(outfile.getAbsoluteFile(), true);
              BufferedWriter bw = new BufferedWriter(fw);
              bw.write(message);
  
              bw.flush(); 
              bw.close();
  
              System.out.println("Done");
  
              } catch (IOException e) {
                  e.printStackTrace();                    
          }    
      }    
  }
  </code></pre>