Results 1 to 3 of 3

Thread: Exception

  1. #1
    Camden is offline Member
    Join Date
    Nov 2007
    Posts
    13
    Rep Power
    0

    Default Exception

    im using this to read a text file
    Java Code:
    try{ blah blah
    while((inputFile = br.readLine()) != null ) {
    but im thinking that if there is a null or more sentences (e.g. between the title and the first paragraph) then it gonna stop reading.. what should i do? throw an exception and make it go back to
    Java Code:
    try{
    ? and how? thanx
    Last edited by Camden; 11-26-2007 at 10:16 PM.

  2. #2
    Camden is offline Member
    Join Date
    Nov 2007
    Posts
    13
    Rep Power
    0

    Default

    anyone? :(

  3. #3
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    but im thinking that if there is a null or more sentences (e.g. between the title and the first paragraph) then it gonna stop reading.. what should i do? throw an exception and make it go back to
    I'm not sure what you mean by this: "a null or more sentences".
    The reader will go on reading until it reaches the end of the file (EOF). When it does it returns "null". With the code you have your while loop will exit gracefully because its listening for this eof condition. If the reader encounters empty lines in the file it will read/return those okay.
    Of course you can always whip up a short test app and a file to read and play around with this to find out how it works and what does/doesn't work.

Similar Threads

  1. Need help on Exception
    By Deon in forum New To Java
    Replies: 7
    Last Post: 02-11-2010, 05:46 PM
  2. Where does the exception go?
    By aytidaalkuhs in forum New To Java
    Replies: 3
    Last Post: 04-07-2008, 02:24 PM
  3. exception
    By Oktam in forum New To Java
    Replies: 2
    Last Post: 03-23-2008, 07:01 PM
  4. Replies: 1
    Last Post: 03-08-2008, 06:41 PM
  5. JSP Exception Hanling
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-24-2007, 09:57 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
  •