Example usage for java.io CharArrayWriter CharArrayWriter

List of usage examples for java.io CharArrayWriter CharArrayWriter

Introduction

In this page you can find the example usage for java.io CharArrayWriter CharArrayWriter.

Prototype

public CharArrayWriter() 

Source Link

Document

Creates a new CharArrayWriter.

Usage

From source file:Main.java

public static void main(String[] args) {
    CharArrayWriter chw = new CharArrayWriter();

    for (int i = 65; i < 70; i++) {
        chw.write(i);//from   www .java  2 s .  com

    }
    String str = chw.toString();
    System.out.println(str);
}

From source file:Main.java

public static void main(String[] args) {

    CharArrayWriter chw = new CharArrayWriter();

    // declare character sequence
    CharSequence csq = "tutorial from java2s.com";

    // append character sequence to the writer
    chw.append(csq, 2, 5);/*from   w  ww.ja va2  s . c  o  m*/

    // prints out the character sequences
    System.out.println(chw.toString());

}

From source file:Main.java

public static void main(String[] args) {
    CharArrayWriter chw = new CharArrayWriter();

    CharSequence csq = "java2s.com";

    // append character sequence to the writer
    chw.append(csq);//from w w  w. j  a v a  2 s  .  c  om

    // flush
    chw.flush();

    // prints out the character sequences
    System.out.println(chw.toString());

}

From source file:Main.java

public static void main(String[] args) {

    CharArrayWriter chw = new CharArrayWriter();

    CharSequence csq = "java2s.com";

    // closes the stream
    chw.close();// www .  j a va  2 s .  c  o m

    // append character sequence to the writer
    chw.append(csq);

    // prints out the character sequences
    System.out.println(chw.toString());

}

From source file:Main.java

public static void main(String[] args) {

    CharArrayWriter chw = new CharArrayWriter();

    // declare character sequences
    CharSequence csq = "java2s.com";
    CharSequence csq1 = "67890";
    CharSequence csq2 = "ABCDE";
    CharSequence csq3 = "abcde";

    // append character sequences to the writer
    chw.append(csq);// w ww.j av a2s . c  o  m
    chw.append(csq1);
    chw.append(csq2);
    chw.append(csq3);

    // prints out the character sequences
    System.out.println(chw.toString());

}

From source file:Main.java

public static void main(String[] args) {

    CharArrayWriter chw = new CharArrayWriter();

    CharSequence csq = "java2s.com";

    // append character sequence to the writer
    chw.append(csq);/*from   w  w w  .j  a  va 2s  . co m*/

    // print character sequence
    System.out.println(csq);

    // invoke reset()
    chw.reset();

    csq = "1234567890";

    chw.append(csq);
    System.out.println(chw.toString());

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    CharArrayWriter chw = new CharArrayWriter();

    String str = "from java2s.com!";

    chw.write(str);//from ww  w .j  ava 2  s  . co m

    // get array of character from the writer
    char[] ch = chw.toCharArray();

    // for each character in character array
    for (char c : ch) {

        // print character
        System.out.println(c);
    }

}

From source file:Main.java

public static void main(String[] args) {

    String str = "from java2s.com!";

    CharArrayWriter chw = new CharArrayWriter();

    // portion to be written to writer
    chw.write(str, 4, 9);/*from   www  .j a  v a 2  s .co  m*/

    // print the buffer as string
    System.out.println(chw.toString());

}

From source file:Main.java

public static void main(String[] args) {

    char[] ch = { 'A', 'B', 'C', 'D', 'E', 'F' };

    CharArrayWriter chw = new CharArrayWriter();

    for (char c : ch) {
        chw.append(c);/*w ww . j av  a  2s . c  o  m*/
    }
    System.out.println(chw.toString());
}

From source file:Main.java

public static void main(String[] args) {

    char[] ch = { 'A', 'B', 'C', 'D', 'E' };

    CharArrayWriter chw = new CharArrayWriter();

    // write character buffer to the writer
    chw.write(ch, 3, 2);/*from ww  w .  ja v a 2 s .c  om*/

    String str = chw.toString();

    System.out.print(str);

}