List of usage examples for java.io CharArrayWriter toString
public String toString()
From source file:Main.java
public static void main(String[] args) throws Exception { String str = "from java2s.com!"; CharArrayWriter chw = new CharArrayWriter(); chw.write(str);//from w w w. j a va 2s . c o m System.out.println(chw.toString()); }
From source file:Main.java
public static void main(String[] args) throws Exception { String str = "from java2s.com!"; CharArrayWriter chw = new CharArrayWriter(100); chw.write(str);/*w w w . j a va2s . 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', 'F' }; CharArrayWriter chw = new CharArrayWriter(); for (char c : ch) { chw.append(c);//from w w w .j a v a 2s .c o m } System.out.println(chw.toString()); }
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);// ww w .ja v a2 s.c o m } String str = chw.toString(); System.out.println(str); }
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);//ww w.j a va 2 s . com String str = chw.toString(); System.out.print(str); }
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);/* ww w . jav 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) throws Exception { char[] ch = { 'A', 'B', 'C', 'D', 'E' }; CharArrayWriter chw = new CharArrayWriter(); // write character buffer to the writer chw.write(ch);/* www . j av a 2 s . com*/ // get buffered content as string String str = chw.toString(); // print the string System.out.print(str); }
From source file:Main.java
public static void main(String[] args) throws Exception { String str = "from java2s.com!"; CharArrayWriter chw = new CharArrayWriter(); // create destination character array writer CharArrayWriter chwd = new CharArrayWriter(); chw.write(str);/*from w w w .j ava2 s.c o m*/ chw.writeTo(chwd); // print the destination buffer content as string System.out.println(chwd.toString()); }
From source file:Main.java
public static void main(String[] args) throws Exception { String str = "from java2s.com!"; CharArrayWriter chw = new CharArrayWriter(); // create destination character array writer CharArrayWriter chwd = new CharArrayWriter(); chw.write(str);/* w ww. j av a 2s . c o m*/ chw.writeTo(chwd); // print the destination buffer content as string System.out.println(chwd.toString()); System.out.println(chwd.size()); }
From source file:CharArrayWriterDemo.java
public static void main(String args[]) throws IOException { CharArrayWriter f = new CharArrayWriter(); String s = "This should end up in the array"; char buf[] = new char[s.length()]; s.getChars(0, s.length(), buf, 0);/*from w ww . j av a 2 s . c om*/ f.write(buf); System.out.println(f.toString()); char c[] = f.toCharArray(); for (int i = 0; i < c.length; i++) { System.out.print(c[i]); } FileWriter f2 = new FileWriter("test.txt"); f.writeTo(f2); f2.close(); f.reset(); for (int i = 0; i < 3; i++) f.write('X'); }