/** * Writes all data written up to the moment to string buffer. * * @param out * @throws IOException */ public char[] toCharArray() { CharBuffer b = firstBuffer; if (b == null) { return new char[0]; } CharBuffer l = b; while (l.getNext() != null) { l = l.getNext(); } char[] result = new char[l.getTotalSize()]; int index = 0; while (b != null) { int s = b.getUsedSize(); System.arraycopy(b.getChars(), 0, result, index, s); index += s; b = b.getNext(); } return result; }
public void printTo(ServletOutputStream outputStream) throws IOException { CharBuffer b = firstBuffer; while (b != null) { outputStream.print(new String(b.getChars())); b = b.getNext(); } }
/** * Writes all data written up to the moment to out. * * @param out * @throws IOException */ public void writeTo(Writer writer) throws IOException { CharBuffer b = firstBuffer; while (b != null) { writer.write(b.getChars(), 0, b.getUsedSize()); b = b.getNext(); } }