title: Passing commands to program as a text file
body: <p>I'm trying to pass the commands in to my program as a text file. I've created a file named <em>commands_in_english.txt</em> and have tried passing in the instructions but it's giving me an error message. Not sure if I'm passing in the file wrong or if I'm missing something in my text file. Any help would be greatly appreciated.</p>
  
  <p>The commands should be passed in to the program as a file with one instruction per line. The English instructions are in <em>thefile commands_in_english.txt</em>. I've called the program by the passing in the instructions as follows:</p>
  
  <pre><code>java ConsoleRobot &lt; commands_in_english.txt
  </code></pre>
  
  <p>This is the program I'm trying to pass the commands to: </p>
  
  <pre><code>import java.util.Scanner;
  public class ConsoleRobot extends SmarterRobot
  {
     public static void main(String [] args)
     {
        World yard = new World();
  
    SmarterRobot ringo = new SmarterRobot();
    yard.add(ringo,5,4);
  
    yard.addBeeper(5,9);
    yard.addBeeper(4,5);
  
    yard.addBeeper(9,4);
    yard.addBeeper(9,5);
  
    Scanner scan = new Scanner(System.in);
    System.out.println("Enter a command: | Introduzca un comando:");
    String command = scan.nextLine();
    command = command.toLowerCase();
  
          while (!command.equals("stop") &amp;&amp; !command.equals("detener"))
    {
    System.out.println("command = "+command);
  
    if ( command.equals("forward") || command.equals("adelante"))
    {
          Scanner reader = new Scanner(System.in);
          System.out.println("How far should the robot move?"); 
          int input = reader.nextInt();  
          ringo.moveNumOfTimes(input);
        }
  
        else if ( command.equals("right") || command.equals("derecha"))
     {
         ringo.turnRight();
         }
  
         else if ( command.equals("left") || command.equals("izquierda"))
    {
       ringo.turnLeft();
        }
  
         else if ( command.equals("collect") || command.equals("recoger"))
        {
      ringo.pickBeeper();
        }
  
     else if ( command.equals("drop") || command.equals("soltar"))
     {
      ringo.putBeeper();
     }
  
        else
     {
       System.out.println("I don't understand! | No entiendo!");
     }
  
        System.out.println("Enter a command: | Introduzca un comando:");
    command = scan.nextLine();
  }
      System.out.println("Finished | Terminado");
  
     }
  }
  </code></pre>