Two Laptop Bag*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How can I use StringBuffer in this case... 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How can I use StringBuffer in this case..." Watch "How can I use StringBuffer in this case..." New topic
Author

How can I use StringBuffer in this case...

Hemal Mehta
Ranch Hand

Joined: Nov 16, 2000
Posts: 101
DataInputStream dis = null;
String textRecord = null;
try {
File f = new File("e:\\staging");
FileInputStream fis = new FileInputStream(f);
BufferedInputStream bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
// read the first record of the database
while ( (textRecord = dis.readLine()) != null) {

}
I want to use StringBuffer instaed of sString to
read the above values from eachh line. How can I do that as readLine returns a String.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Simple - just use the String that is returned by readLine as an argument to the append method of StringBuffer, like this:

Hope that helps,
Corey


SCJP Tipline, etc.
 
wood burning stoves
 
subject: How can I use StringBuffer in this case...
 
Similar Threads
Convert file to a String
Dynamically reading a file
DataOutputStream
writing data to CSV file
how exactly can i make out if a file in linux has just been updated or has been replaced.