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();
   }
 }
 public void resetBuffers() throws IOException {
   if (caw != null) {
     caw.reset();
   } else if (bawos != null) {
     bawos.resetByteArray();
   }
 }
 public byte[] getBytes() {
   if (bawos != null) {
     return bawos.toByteArray();
   }
   return null;
 }