Home Tutorial Java Core Files Java file StringWriter

 
 

Java file StringWriter
Posted on: April 26, 2006 at 12:00 AM
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.

Related Tags for Java file StringWriter:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.