Java: Trouble Catching IOException

Discussion in 'OT Technology' started by cheet, Jun 3, 2006.

  1. cheet

    cheet OT Supporter

    Joined:
    Mar 22, 2004
    Messages:
    13,235
    Likes Received:
    3
    Location:
    CA
    Generator.java:28: exception java.io.IOException is never thrown in body of corresponding try statement
    catch (IOException e)

    Here's my main class, and where the error occurs...

    Code:
     
    import java.io.IOException;
    public class Generator
    {
     public static void main(String[] args)
     {
      if (args.length < 1)
      {
       System.out.println("Error! You need to enter a grammar file and parameters in command line");
       System.exit(-1);
      }
      else
      {
       try
       {
        Creator creator = new Creator(args[0], args[1], args[2], args[3]);
        creator.go();
       }
       catch (IOException e)
       {
        System.out.println("Could not read grammar file from" + args[0]);
       }
      }
     }
    }
     
    
    What's wrong here? I've made java programs very similar to this before and had no trouble.
     
  2. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Creator doesn't throw that exception.
     
  3. uofapeter

    uofapeter New Member

    Joined:
    Apr 23, 2004
    Messages:
    19,163
    Likes Received:
    0
    try changing it to
    catch(Exception e)
     

Share This Page