Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes I/O and Streams and the fly likes Read a Flat File line by line and add it to a StringBuffer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Read a Flat File line by line and add it to a StringBuffer" Watch "Read a Flat File line by line and add it to a StringBuffer" New topic
Author

Read a Flat File line by line and add it to a StringBuffer

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,

I am trying to read a Flat File which is line by line "\n" new line seperated .
I want to read each line and add it to a StringBuffer .

I tried this way ,but its not working .Please help




Save India From Corruption - Anna Hazare.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

You never change item. You read one line, then keep using the same line over and over.

You'll see that usually one of the following (nearly identical) loops is used:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you , Rob , you were always there to help .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Read a Flat File line by line and add it to a StringBuffer
 
Similar Threads
unable to exit program..
FileReader / BufferedReader will only read the first line from the file
Can Jsp be converted into String
Do I need to use a stringbuffer?
How to Read a Flat File Data