Results 1 to 2 of 2
  1. #1
    McChill is offline Member
    Join Date
    Feb 2009
    Rep Power

    Default Unhandled exception

    Java Code:
    BufferedReader dataIn = new BufferedReader(new InputStreamReader(;
    			temp = dataIn.readLine();
    		}catch(IOException e) {
    			System.out.println("Error in getting input.");
    		if(temp == "switch")
    			System.out.println("Okay, what two lines should be switched?");
    			String which = dataIn.readLine();
    The compiler is telling me Unhandled exception type IOException on the last line of that block of code. I'm unsure what it is exactly trying to tell me. I tried to google the topic but I couldn't really find an answer that fit.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    Read the Sun tutorial on exceptions to understand more about this.

    Also, you could place the if (temp... block within the try block.

    Also: don't compare Strings with ==. Use the equals method instead.
    Java Code:
    // NOT this
    if (temp == "switch"))
    // but THIS
    if (temp.equals("switch"))

Similar Threads

  1. Need Help with exception
    By maggie_2 in forum New To Java
    Replies: 7
    Last Post: 11-27-2008, 12:45 AM
  2. Re:SQL Exception
    By jyotigupta6 in forum New To Java
    Replies: 1
    Last Post: 10-28-2008, 10:37 AM
  3. exception
    By Oktam in forum New To Java
    Replies: 2
    Last Post: 03-23-2008, 08:01 PM
  4. Replies: 1
    Last Post: 03-08-2008, 07:41 PM
  5. Exception
    By Camden in forum New To Java
    Replies: 2
    Last Post: 11-27-2007, 12:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts