Java StringWriter append() Example

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


Syntax is : public StringWriter append(CharSequence csq, int start, int end)
This method appends a subsequence of the specified character sequence to this StringWriter. This method behaves in exactly the same way as the invocation out.write(csq.subSequence(start, end).toString()).

Here is the code.
/**
 * @(#) Append2StringWriter.java
 * A class representing use of method append() of StringWriter class in 
 java.io Package.
 * @Version  28-May-2008
 @author   Rose India Team
 */
import java.io.*;
public class Append2StringWriter {
    public static void main(String[] args){
        // Create object of StringWriter class.
        StringWriter objStringWriter = new StringWriter();
        String str = "This is Rose India Pvt.";
        System.out.println("Given string is : " + str);
        // append() method call.
        objStringWriter.append(str, 818);
        System.out.println("Specified substring is appended successfully!");
        System.out.print("String in string buffer is : " + objStringWriter);
    }
}

Output of the program.
Given string is : This is Rose India Pvt.
Specified substring is appended successfully!
String in string buffer is : Rose India

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

HOME | COPYRIGHT | CONTACT US