title: How to use "or" in Java?
body: <p>I'm trying to write a program that allows you to check 2 different kind of animals into a shelter (dogs and cats). When you run the program, you're asked which animal you're entering into the system and, depending on the answer, the corresponding file (.txt) is selected to read and write from.</p>
  
  <p>I'm having an issue with choosing the file when ran through the console, and error catching if neither "dog" or "cat" is entered.</p>
  
  <p>Here's the current code:</p>
  
  <pre><code>private KennelDemo() {
      scan = new Scanner(System.in);
      System.out.print("Are you checking a dog or cat into the kennel? Enter 'dog' or 'cat': ");
  
      // Try to allocate the correct file to the String fileChosen
  
      /*
       * TODO
       * kennel should not run if "cat" or "dog" hasn't been entered. While loop?
       */
  
  
      try {
          fileChosen = scan.next();
              if(fileChosen == "dog")
                  fileChosen = dogsFile;
              else if 
                  (fileChosen == "cat")
                  fileChosen = catsFile;
  
      }
  
  
      catch (Exception IOException) {
          System.out.println("Please enter either 'dog' or 'cat', nothing else.");
  
                                    }
  
  
      kennel = new Kennel();
  }
  </code></pre>
  
  <p>The entry process should be:</p>
  
  <pre><code>Enter dog or cat when prompted
  If "cat is entered, the system reads and writes from cats.txt
  If Dog is selected "dogs.txt" is read from and written to.
  If neither is entered, the system catches the error and returns the user to the selection process.
  </code></pre>
  
  <p>What happens is:</p>
  
  <pre><code>When you enter "dog" or "cat", the catch error prints the error line regardless and then it tries to run Kennel();.
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Here are the variables declared:</p>
  
  <pre><code>public class KennelDemo {
  private Kennel kennel; // holds the kennel
  private Scanner scan; // so we can read from keyboard
  private String dogsFile = "./dogs.txt"; // hardcodes file for the information regarding dogs
  private String catsFile = "./cats.txt"; // hardcodes file for the information regarding cats
  private String fileChosen; // String to contain the filename entered by the user and then ran with through the method KennelDemo()
  </code></pre>
  
  <p>Any help with this at all?</p>
  
  <p>Thanks.</p>