1.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java Fri Oct 12 14:53:50 2012 -0700 1.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java Mon Oct 15 17:07:55 2012 -0700 1.3 @@ -25,6 +25,10 @@ 1.4 1.5 package com.sun.tools.doclets.internal.toolkit; 1.6 1.7 +import java.io.IOException; 1.8 +import java.io.StringWriter; 1.9 +import java.io.Writer; 1.10 + 1.11 import com.sun.tools.doclets.internal.toolkit.util.*; 1.12 1.13 /** 1.14 @@ -44,10 +48,16 @@ 1.15 * 1.16 * @return string representation of the content 1.17 */ 1.18 + @Override 1.19 public String toString() { 1.20 - StringBuilder contentBuilder = new StringBuilder(); 1.21 - write(contentBuilder); 1.22 - return contentBuilder.toString(); 1.23 + StringWriter out = new StringWriter(); 1.24 + try { 1.25 + write(out, true); 1.26 + } catch (IOException e) { 1.27 + // cannot happen from StringWriter 1.28 + throw new DocletAbortException(); 1.29 + } 1.30 + return out.toString(); 1.31 } 1.32 1.33 /** 1.34 @@ -65,10 +75,10 @@ 1.35 public abstract void addContent(String stringContent); 1.36 1.37 /** 1.38 - * Writes content to a StringBuilder. 1.39 + * Writes content to a writer. 1.40 * 1.41 */ 1.42 - public abstract void write(StringBuilder contentBuilder); 1.43 + public abstract boolean write(Writer writer, boolean atNewline) throws IOException ; 1.44 1.45 /** 1.46 * Returns true if the content is empty.