File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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

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,

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