From 688634ae5a5aaf663159032e67d2132ea61c5d5f Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 4 May 2014 17:37:41 +0200 Subject: Implement "save" and "load" --- src/rejava/io/StringWriter.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/rejava/io/StringWriter.java (limited to 'src/rejava/io/StringWriter.java') diff --git a/src/rejava/io/StringWriter.java b/src/rejava/io/StringWriter.java new file mode 100644 index 0000000..cee4c97 --- /dev/null +++ b/src/rejava/io/StringWriter.java @@ -0,0 +1,29 @@ +package rejava.io; + +/** + * A minimal subset of java.io.StringReader. + * (http://hg.openjdk.java.net/jdk7/jdk7/jdk/file + * /9b8c96f96a0f/src/share/classes/java/io/StringWriter.java) + * + * @author Pacien TRAN-GIRARD + */ +public class StringWriter extends Writer { + + private final StringBuilder buf = new StringBuilder(); + + @Override + public void write(final String str) { + this.buf.append(str); + } + + @Override + public void write(final char c) { + this.buf.append(c); + } + + @Override + public String toString() { + return this.buf.toString(); + } + +} \ No newline at end of file -- cgit v1.2.3