implement StringWriter.getBuffer

This is used by json.org's JSON library.
This commit is contained in:
Joel Dice 2014-10-28 14:52:02 -06:00
parent e41133d268
commit f25d5921a5

View File

@ -11,7 +11,7 @@
package java.io; package java.io;
public class StringWriter extends Writer { public class StringWriter extends Writer {
private final StringBuilder out = new StringBuilder(); private final StringBuffer out = new StringBuffer();
public void write(char[] b, int offset, int length) throws IOException { public void write(char[] b, int offset, int length) throws IOException {
out.append(b, offset, length); out.append(b, offset, length);
@ -24,4 +24,8 @@ public class StringWriter extends Writer {
public void flush() throws IOException { } public void flush() throws IOException { }
public void close() throws IOException { } public void close() throws IOException { }
public StringBuffer getBuffer() {
return out;
}
} }