提示

Java IO StringWriter 使用示例。@ermo

    public static void write() throws IOException {
        String data = "Some simple data.";
        StringWriter out = new StringWriter();
        try {
            out.write(data);
            System.out.println(out);

            System.out.println(out.getBuffer());
        } finally {
            out.close();
        }
    }

    public static void main(String[] args) throws IOException {
        write();
    }