Package pygmy.core

Source Code of pygmy.core.PrintWriterResponseData

package pygmy.core;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.OutputStream;
import java.io.IOException;

public class PrintWriterResponseData implements ResponseData {
    PrintWriter writer;
    StringWriter backEnd;

    public PrintWriterResponseData() {
        backEnd = new StringWriter();
        writer = new PrintWriter( backEnd );
    }

    public long getLength() {
        writer.flush();
        return backEnd.getBuffer().length();
    }

    public PrintWriter getPrintWriter() {
        return writer;
    }

    public void send(OutputStream os) throws IOException {
        writer.flush();
        os.write( backEnd.toString().getBytes() );
    }
}
TOP

Related Classes of pygmy.core.PrintWriterResponseData

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.