Results 1 to 3 of 3
- 11-26-2012, 08:39 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 1
- Rep Power
- 0
bufferedreader question, please help.
hi
I'm using bufferedreader to read a file now.
How can I say, if the next line is null (without jumping to the next line ), then do something. (say, print helloworld)
It's like, i want to have a function "boolean hasNextLine()". Please provide me the code and syntax if you can.
Thank you.
- 11-26-2012, 11:21 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: bufferedreader question, please help.
You can't.
Here's the API for BufferedReader.
All you have (on top of the standard read() methods) is a readLine() method.
It doesn't have a way to test whether there's a line.
If you think about it a while you'll see that that would not be possible in most cases where the BufferedReader would be used to wrap a stream.Please do not ask for code as refusal often offends.
- 11-26-2012, 11:50 AM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
Re: bufferedreader question, please help.
If you accept a restriction (a maximum line length), it can be done:
But I find this whole thing a sily academic exercise with no practical use ...Java Code:br.mark(maxlineLength); boolean hasLine= br.readLine() != null; br.reset();
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Using BufferedReader
By hqt in forum New To JavaReplies: 1Last Post: 12-09-2011, 04:12 AM -
How to use BufferedReader?
By ProgramBeginner in forum New To JavaReplies: 4Last Post: 10-11-2011, 02:56 PM -
use of BufferedReader?please help
By Cosmos in forum New To JavaReplies: 11Last Post: 07-17-2011, 04:55 PM -
BufferedReader, need help!
By zacharyrod in forum New To JavaReplies: 10Last Post: 11-19-2009, 10:56 AM -
BufferedReader
By vidhya.sk in forum New To JavaReplies: 2Last Post: 09-18-2008, 01:57 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks