This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes BufferedReader.readLine() method. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "BufferedReader.readLine() method." Watch "BufferedReader.readLine() method." New topic
Author

BufferedReader.readLine() method.

Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
I need to read a file line by line and put it in different variables depending upon some condition.
I am using,
BufferedReader para;
while((line = para.readLine()) != null)
two of the lines in paragraph are
1. this is suresh's
2. key for the home.
wheen i read line 1 and print the line i see that
line = "this is suresh''s"
note that ' has been appended by one more '.
Why is that ?
If i dont want that to happen. what should i be doing?
thnaks.
Such case can happen only one in while in along paragraph.

Thanks!!
Sigfred Zamo
Ranch Hand

Joined: Mar 04, 2002
Posts: 44
I�ve remade a similar example:

having pr.txt:

and the output:

(it works ok for me..)


Sigfred Zamo<br />Software Development<p><a href="http://www.sigfredo.ingenieros.net/index2.html" target="_blank" rel="nofollow">My page</a>
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Thanks Sigfred!!
oops !! I did not mention that my para is defined this way.
BufferedReader para = new BufferedReader(new InputStreamReader(stream));
Is there any way that without changing this i get the proper output?
Thanks!!
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Building off this example, I compiled the following:

And again, the output comes out as "Saresh's", single quote. What is your variable stream representing?
Sigfred Zamo
Ranch Hand

Joined: Mar 04, 2002
Posts: 44
Well, I tried this way:

..and I got the same result..
try copypasting your code..
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Oho...
I did not realise that Sigfred is suggesting that
your code should give result you want as is!!

Sorry guys I see that the get method from some one elses class which i am using here seem to be producing my problem (never trust blindly
Thanks for all your responses.....
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Can someone point me to a method to replace
'' marks from a string with single '
e. g
suresh''s key is in the room near mahesh''s room.
should produce result,
suresh's key is in the room near mahesh's room.
Doanh Nguyen
Ranch Hand

Joined: Dec 02, 2000
Posts: 45
I asked a similar question recently:
http://www.coderanch.com/t/391421/java/java/Replace-substring
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Thanks Doanh!!
That was very helpful link...
It saved lot of my time....
Thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BufferedReader.readLine() method.
 
Similar Threads
Scanning a text file
formating outFile
K&B Errata
Punction Correct (Sentances)
Array counters