title: Java code to save a variable to a a text file
body: <p>I need code to write a single line like <code>Aidan Dowling</code> to a text file.
  My code so far is:</p>
  
  <pre><code>package battleships.startmenu;
  import java.util.Scanner;
  public class Startmenu {
  
      public static void main(String[] args) {
          System.out.print("Hello! Please enter your first name: ");
          Scanner reader = new Scanner(System.in);
          String a;
          String b;
          a=reader.next();
          System.out.print("Enter your second name: ");
          b=reader.next();
  
          System.out.println("Hello " + a+ " " + b + "!");
          System.out.println("\tHello");
          String name;
          name = a + b;
      }
  }
  </code></pre>
  
  <p>I want the variable name to print out to a document called name.txt</p>