1 /* 2 * Copyright (c) 2005-2007 Creative Sphere Limited. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * 10 * Creative Sphere - initial API and implementation 11 * 12 */ 13 package org.abstracthorizon.danube.http.util; 14 15 import java.io.PrintWriter; 16 import java.io.StringWriter; 17 18 /** 19 * String print writer implementation 20 * 21 * @author Daniel Sendula 22 */ 23 public class StringPrintWriter extends PrintWriter { 24 25 /** 26 * Constructor 27 * 28 */ 29 public StringPrintWriter() { 30 super(new StringWriter()); 31 } 32 33 /** 34 * Retruns string buffer of a print writer 35 * @return string buffer of a print writer 36 */ 37 public StringBuffer getStringBuffer() { 38 return ((StringWriter)out).getBuffer(); 39 } 40 41 /** 42 * Resets the string buffer by deleting its contents 43 * 44 */ 45 public void reset() { 46 StringBuffer buf = getStringBuffer(); 47 buf.delete(0, buf.length()); 48 } 49 50 }