title: Export Data from Java to a text file
body: <p>I want to export the character's name and gender to a text file. Also, I need to export on both Mac and PC computers. I've tried various methods, but none has worked for me or I might have placed them incorrectly.</p>
  
  <p>I changed my code with my attempt:</p>
  
  <pre><code>import java.util.Scanner;
  import java.io.PrintWriter;
  import java.io.File;
  import java.util.Scanner;
  
  public class Character {
  
      public static void main (String[] args) {
          String characterGender;
          String characterName;
  
          Scanner scan = new Scanner(System.in);
  
          System.out.println("Welcome to Ricardo's character creator!");
  
          System.out.println("Is your character a boy or a girl?");
          characterGender = scan.nextLine();
  
          if (characterGender.equals("girl"))  {
               System.out.println("Awesome! Please enter her name: ");
               characterName = scan.nextLine();
          } else {
               System.out.println("Awesome! Please enter his name: ");
               characterName = scan.nextLine();
          }
  
          System.out.print("Alright! " + characterName + " has been created!");
  
          PrintWriter out = new PrintWriter("Character.txt");
          out.println(characterName);
          out.println(characterGender);
          out.close();
  
      }
  }
  </code></pre>
  
  <p>I'm getting an error like this:</p>
  
  <blockquote>
    <p>Character.java:34: error: unreported exception FileNotFoundException; must be caught or declared to be thrown.</p>
  </blockquote>