Results 1 to 3 of 3
Thread: Exception
- 11-26-2007, 10:13 PM #1
Member
- Join Date
- Nov 2007
- Posts
- 13
- Rep Power
- 0
Exception
im using this to read a text file
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 toJava Code:try{ blah blah while((inputFile = br.readLine()) != null ) {? and how? thanxJava Code:try{Last edited by Camden; 11-26-2007 at 10:16 PM.
- 11-26-2007, 11:16 PM #2
Member
- Join Date
- Nov 2007
- Posts
- 13
- Rep Power
- 0
anyone? :(
- 11-26-2007, 11:50 PM #3
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
-
Need help on Exception
By Deon in forum New To JavaReplies: 7Last Post: 02-11-2010, 05:46 PM -
Where does the exception go?
By aytidaalkuhs in forum New To JavaReplies: 3Last Post: 04-07-2008, 02:24 PM -
exception
By Oktam in forum New To JavaReplies: 2Last Post: 03-23-2008, 07:01 PM -
Trouble with factory method - unhandled exception type Exception
By desmond5 in forum New To JavaReplies: 1Last Post: 03-08-2008, 06:41 PM -
JSP Exception Hanling
By Java Tip in forum Java TipReplies: 0Last Post: 12-24-2007, 09:57 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks