Home Tutorial Java Core Files Java file StringWriter

 
 

Share on Google+Share on Google+
Java file StringWriter
Posted on: April 26, 2006 at 12:00 AM
Advertisement
his section demonstrates you the use of StringWriter class.

Java file StringWriter

This section demonstrates you the use of StringWriter class.

StringWriter is a character stream that collects its output in a string buffer, which can then be used to construct a string. In other words, you can say it enables to obtain the characters written to a Writer as a string. Closing a StringWriter has no effect.

append(): This method of StringWriter class appends the specified character to the writer.

write(): This method of StringWriter class write the string to the writer.

Here is the code:

import java.io.*;

public class FileStringWriter {
	public static void main(String[] args) throws Exception {
		StringWriter obj = new StringWriter();
		obj.append("Rose ");
		obj.append("India ");
		obj.write("Technologies Pvt Ltd");
		System.out.println("String: " + obj);
	}
}

The above code will definitely explains you the concept of StringWriter.

Advertisement

Related Tags for Java file StringWriter:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 26, 2006

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com