1 /* Copyright (c) 2008, Avian Contributors 2 3 Permission to use, copy, modify, and/or distribute this software 4 for any purpose with or without fee is hereby granted, provided 5 that the above copyright notice and this permission notice appear 6 in all copies. 7 8 There is NO WARRANTY for this software. See license.txt for 9 details. */ 10 11 package java.io; 12 13 public class StringWriter extends Writer { 14 private final StringBuilder out; 15 StringWriter()16 public StringWriter() { 17 out = new StringBuilder(); 18 } 19 StringWriter(int initialCapacity)20 public StringWriter(int initialCapacity) { 21 out = new StringBuilder(initialCapacity); 22 } 23 write(char[] b, int offset, int length)24 public void write (char[] b, int offset, int length) throws IOException { 25 out.append(b, offset, length); 26 } 27 toString()28 public String toString () { 29 return out.toString(); 30 } 31 flush()32 public void flush () throws IOException { 33 } 34 close()35 public void close () throws IOException { 36 } 37 } 38