title: Java: How to continue reading a file after an exception is thrown
body: <p>so my professor has assigned us a project where we have to take in commands from a text file and use them to drive the flow of our program. These commands such as- Takeoff, land, load cargo, unload cargo, etc.- are meant to simulate an airplane-like object.</p>
  
  <p>Sometimes these commands don't make sense to execute, like loading cargo while a plane is in-flight. Therefore, to prevent something like that from happening we had to code in our own exception classes i.e. <strong>"If the plane is ordered to load cargo while in flight, throw InvalidActionException"</strong></p>
  
  <p>My question is: how can I <strong>continue</strong> to read-in commands from the text file after exceptions have been thrown (seeing as how once they are thrown, the program cannot progress further</p>
  
  <p>Here's an outline of what I want to do:</p>
  
  <pre><code>    Scanner input = new Scanner(new FileInputStream("stuff1.txt"));
  
      while(input.hasNextLine())
      {
          try 
          {
               //execute commands by reading them using input.nextLine()
          }
          catch()
          {
              //catch any exceptions and ignore them... continue to read
             //the file for more commands
          }
      }
  </code></pre>
  
  <p>I would appreciate any help. Thanks.</p>