Java StringWriter getBuffer() Example

StringWriter class getBuffer() method example. This example shows you how to use getBuffer() method.


Syntax is : public StringBuffer getBuffer()
This method returns the string buffer itself.

Here is the code.
/**
 * @(#) GetBufferStringWriter.java
 * A class representing use of method getBuffer() of StringWriter class in 
 java.io Package.
 * @Version  29-May-2008
 @author   Rose India Team
 */
import java.io.*;
public class GetBufferStringWriter {
     public static void main(String[] args){

        // Create object of StringWriter class
        StringWriter objStringWriter = new StringWriter();
        // append() method call.
        objStringWriter.append("Rose ");
    objStringWriter.append("India");
        System.out.println("String in string buffer is : " + objStringWriter);
    // getBuffer() method call.
    StringBuffer strBuffer = objStringWriter.getBuffer();
    System.out.println("String Buffer is : " + strBuffer);
    }
}

Output of the program.
String in string buffer is : Rose India
String Buffer is : Rose India

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US