diff options
Diffstat (limited to 'src/rejava/io/StringWriter.java')
-rw-r--r-- | src/rejava/io/StringWriter.java | 29 |
1 files changed, 29 insertions, 0 deletions
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 @@ | |||
1 | package rejava.io; | ||
2 | |||
3 | /** | ||
4 | * A minimal subset of java.io.StringReader. | ||
5 | * (http://hg.openjdk.java.net/jdk7/jdk7/jdk/file | ||
6 | * /9b8c96f96a0f/src/share/classes/java/io/StringWriter.java) | ||
7 | * | ||
8 | * @author Pacien TRAN-GIRARD | ||
9 | */ | ||
10 | public class StringWriter extends Writer { | ||
11 | |||
12 | private final StringBuilder buf = new StringBuilder(); | ||
13 | |||
14 | @Override | ||
15 | public void write(final String str) { | ||
16 | this.buf.append(str); | ||
17 | } | ||
18 | |||
19 | @Override | ||
20 | public void write(final char c) { | ||
21 | this.buf.append(c); | ||
22 | } | ||
23 | |||
24 | @Override | ||
25 | public String toString() { | ||
26 | return this.buf.toString(); | ||
27 | } | ||
28 | |||
29 | } \ No newline at end of file | ||