Forums Register Login

readLine(boolean)

+Pie Number of slices to send: Send
Hi All!

I was reading the BufferedReader class source code and came across a function called readLine(boolean ignoreLF). When I saw the public readLine() function which we can use through an object of BufferedReader, I realized that readLine() calls the readLine(boolean ignoreLF) with a false parameter. I understood that this is the reason why readLine() cannot read two lines terminated by \n.

I'm wondering if it is possible to call the readLine(boolean) by sending it a true parameter (either directly or indirectly). I know I have other options (e.g. by using read()), but I just want to try it out using readLine(boolean)

Any help?

Thanks!

Regards,
Shobit

+Pie Number of slices to send: Send
Welcome to the Ranch!

If you looked at the source code, you saw that the method is not public; it has no access modifier and therefore has only package visibility. That means you cannot call it; the Javadoc page reflects this.
+Pie Number of slices to send: Send
Thanks!

So is there no way that I can make the readLine() read a line and not terminate at the \n ?
E.g. for reading the Http Request in which the request-line and header are separated by \r\n?

(I'm just trying this as a challenge...I know there are other ways )
+Pie Number of slices to send: Send
As far as I know, if readLine() encounters an empty line (with only \r\n or \n), it will simply return an empty String.
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1397 times.
Similar Threads
empty vector cells
Reading a text file
can not open the file
File Reading
DataInputStream
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 00:13:15.