Java CharArrayWriter write char array

Description

Java CharArrayWriter write char array

import java.io.CharArrayWriter;
import java.io.IOException;

public class Main {
  public static void main(String args[]) throws IOException {
    CharArrayWriter outStream = new CharArrayWriter();
    String s = "This is a test from demo2s.com.";
    for (int i = 0; i < s.length(); ++i)
      outStream.write(s.charAt(i));/* w  ww .ja va  2s.c  o  m*/
    System.out.println("outstream: " + outStream);
    System.out.println("size: " + outStream.size());
    
  }
}



PreviousNext

Related