public void resetBuffers() throws IOException {
   if (caw != null) {
     caw.reset();
   } else if (bawos != null) {
     bawos.resetByteArray();
   }
 }
 public void flushToWriter(Writer writer, String encoding) throws IOException {
   if (caw != null) {
     pw.flush();
     caw.writeTo(writer);
     caw.reset();
   } else if (bawos != null) {
     bawos.writeTo(writer, encoding);
     bawos.resetByteArray();
   }
   writer.flush();
 }
 public void flushContentToWrappedResponse() throws IOException {
   if (caw != null) {
     pw.flush();
     caw.writeTo(response.getWriter());
     caw.reset();
   } else if (bawos != null) {
     try {
       bawos.writeTo(response.getWriter(), response.getCharacterEncoding());
     } catch (IllegalStateException ise) {
       bawos.writeTo(response.getPortletOutputStream());
     }
     bawos.resetByteArray();
   }
 }