title: Error Handling java program
body: <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.Scanner;
  
  public class Asterisks
  {
      public static void main(String[] args) 
      {
          try
          {
              File dataFile = new File("Asterisks.txt"); \\ this file says "S 3"
              Scanner in = new Scanner(dataFile);
              String shapeType = in.next(); 
              int Dim = in.nextInt(); 
  
              if (shapeType.equals("S"))
              {
                  for(int loop = 0; loop &lt; 4; loop ++)
                  {
                      for (int line = 0; line &lt; Dim; line ++)
                      {
                          for(int elt = 0; elt &lt; Dim; elt ++)
                          {
                              System.out.println(" *");
                          }
                          System.out.println(" ");
                      }                                            
                   }                                                   
              }        
          }
          catch (FileNotFoundException e)
          {
              System.out.println("Data file not found.");
          }    
      }
  }
  </code></pre>
  
  <p>(first time putting it on here so please write on the comments what i can do to make it better)
  So this is my file and what I don't get is that why this program does not run.</p>
  
  <p>this file has to print out</p>
  
  <pre><code>      * * *
        * * *
        * * *
  </code></pre>
  
  <p>the output im getting right now is</p>
  
  <pre><code>Exception in thread "main" java.util.InputMismatchException
      at java.util.Scanner.throwFor(Unknown Source)
      at java.util.Scanner.next(Unknown Source)
      at java.util.Scanner.nextInt(Unknown Source)
      at java.util.Scanner.nextInt(Unknown Source)
      at Asterisks.main(Asterisks.java:15)
  </code></pre>
  
  <p>Thank for your help in advance.</p>