/*
Chararraywriter implements the output stream with arrays as the target. Chararraywriter has two constructor functions: chararraywriter () chararraywriter (INT numchars) in the first form. A buffer of the default length is created. Second, the buffer length is specified by numchars. The buffer is stored in the Buf member of chararraywriter. The buffer size can automatically increase as needed. The number of characters maintained by the buffer is included in the count member of chararraywriter. Both Buf and count are protected domains.
*/
// Demonstrate chararraywriter.
Import java. Io .*;
Class chararraywriterdemo {
Public static void main (string [] ARGs) throws ioexception {
Chararraywriter F = new chararraywriter ();
String S = "This shocould end up in the array ";
Char Buf [] = new char [S. Length ()];
S. getchars (0, S. Length (), Buf, 0 );
F. Write (BUF );
System. Out. println ("buffer as a string ");
System. Out. println (F. tostring ());
System. Out. println ("into array ");
Char C [] = f. tochararray ();
For (INT I = 0; I <C. length; I ++ ){
System. Out. Print (char) C [I]);
}
System. Out. println ("/nto a filewriter ()");
Filewriter F2 = new filewriter ("test.txt ");
F. writeto (F2 );
F2.close ();
System. Out. println ("doing a reset ");
F. Reset ();
For (INT I = 0; I <3; I ++)
F. Write ('x ');
System. Out. println (F. tostring ());
}
}