Results 1 to 3 of 3
  1. #1
    Tealoon is offline Member
    Join Date
    Sep 2009
    Posts
    2
    Rep Power
    0

    Default close and reopen BufferedReader

    I want to close and read file again with BufferedReader, here's the code:

    Java Code:
    in.close();
    BufferedReader in = openfile(args[0]);
    The compiler give me following message:
    Java Code:
    TakeHome1.java:34: in is already defined in main(java.lang.String[])
    BufferedReader in = openfile(args[0]);		
                   ^
    Can't figure out what's wrong... How can I fix this?

  2. #2
    Tealoon is offline Member
    Join Date
    Sep 2009
    Posts
    2
    Rep Power
    0

    Default

    I just figured it out, but there's a different problem. Now it looks like this:
    Java Code:
    		in.close();
    		in = openfile(args[0]);
    TakeHome1.java:33: unreported exception java.io.IOException; must be caught or declared to be thrown
    in.close();


    ... How do I throw exception for in.close(); ? I'm not even sure why I need exception for that.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Similar Threads

  1. How to use BufferedReader?
    By ProgramBeginner in forum New To Java
    Replies: 4
    Last Post: 10-11-2011, 02:56 PM
  2. how can i make bufferedreader
    By chyeeqi in forum New To Java
    Replies: 4
    Last Post: 08-21-2009, 05:24 PM
  3. Close but help would be grateful
    By reader34 in forum New To Java
    Replies: 8
    Last Post: 12-21-2008, 05:42 PM
  4. BufferedReader
    By vidhya.sk in forum New To Java
    Replies: 2
    Last Post: 09-18-2008, 01:57 PM
  5. Help with BufferedReader in java
    By carl in forum New To Java
    Replies: 2
    Last Post: 07-31-2007, 07:20 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
  •