Results 1 to 6 of 6

Thread: File i/o

  1. #1
    Rubel Rana is offline Member
    Join Date
    Jul 2013
    Posts
    14
    Rep Power
    0

    Default File i/o

    #

    import java.io.*;
    class BRRead {
    public static void main(String args[])
    throws IOException
    {
    char c;
    BufferedReader br = new
    BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter characters, 'q' to quit.");
    // read characters
    do {
    c = (char) br.read();
    System.out.println(c);
    } while(c != 'q');
    }
    }
    #

    My question is why "throws IOException" is used?wht its task?
    Last edited by Rubel Rana; 07-27-2013 at 10:28 AM. Reason: Removed link

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: File i/o

    Post the code here. Before that go through these pages:
    Guide For New Members
    BB Code List - Java Programming Forum - Learn Java Programming

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    kumarjivi is offline Member
    Join Date
    Jun 2013
    Location
    India
    Posts
    5
    Rep Power
    0

    Default Re: File i/o

    As your program may generate IOExceotion, so you need to handle it, You may have done this by using try-catch block or there is a second option:- use throws.
    So the exeption will not be handled by this method instead it is thrown (by using throws) to the caller of this method. And now, its the responsibility of the caller to handle it.

    Hope it helps. :)

  4. #4
    Rubel Rana is offline Member
    Join Date
    Jul 2013
    Posts
    14
    Rep Power
    0

    Default Re: File i/o

    Really it helps me.
    thx :)

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: File i/o

    Is it really too much trouble to go through 2 pages on this site and learn how to post code properly?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    Rubel Rana is offline Member
    Join Date
    Jul 2013
    Posts
    14
    Rep Power
    0

    Default Re: File i/o

    Actually i go the pages,but it looks fishy to me,anyway,im going again,try to find out what you want?

Similar Threads

  1. Replies: 0
    Last Post: 12-15-2012, 01:37 AM
  2. Replies: 15
    Last Post: 02-16-2012, 03:43 PM
  3. Replies: 1
    Last Post: 07-28-2011, 07:50 PM
  4. Replies: 0
    Last Post: 02-11-2009, 09:53 AM
  5. Replies: 7
    Last Post: 05-23-2008, 03:46 AM

Tags for this Thread

Posting Permissions

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