String Buffer To File
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class JavaStringBufferToFileExample
{
public static void main(String[] args)
throws IOException
{
StringBuffer
sbf = new StringBuffer();
sbf.append("StringBuffer contents first
line.");
sbf.append(System.getProperty("line.separator"));sbf.append("StringBuffer
contents second line.");
BufferedWriter bwr = new BufferedWriter(new
FileWriter(new File("d:/demo.txt")));
bwr.write(sbf.toString());
bwr.flush();
bwr.close();
System.out.println("Content of
StringBuffer written to File.");
}
}
No comments:
Post a Comment