Java CharArrayWriter write() Example

CharArrayWriter class write() method example. This example shows you how to use write() method.


Syntax is : public void write(String str, int off, int len)
This method write a portion of a string to the buffer. Description of parameters :-
    str - String to be written from
    off - Offset from which to start reading characters
    len - Number of characters to be written

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

    String str = "MAHENDRA SINGH";

        // Create object of CharArrayWriter class.
        CharArrayWriter objCharArrWriter = new CharArrayWriter();

    // write() method call.
        objCharArrWriter.write(str, 014);
        System.out.print("After write a sub string, char "
    "buffer is : " + objCharArrWriter);
    }   
}

Output of the program.
After write a sub string, char buffer is : MAHENDRA SINGH

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

HOME | COPYRIGHT | CONTACT US