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 writer * @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(); } }
System.arraycopy(current.getChars(), index, cbuf, off, av); index += av; off += av;
/** * Writes rest of data written up to the moment to out. * * @param writer * @throws IOException */ public void writeTo(Writer writer) throws IOException { if (current == null) { return; } if (current.getUsedSize() > index) { writer.write(current.getChars(), index, current.getUsedSize() - index); current = current.getNext(); } while (current != null) { writer.write(current.getChars(), 0, current.getUsedSize()); current = current.getNext(); } index = 0; } }
/** * Writes all data written up to the moment to out. * * @param out * @throws IOException */ public void writeTo(Writer out, String encoding) throws IOException { ByteBuffer b = getFirstBuffer(); while (b != null) { CharBuffer c = b.toCharBuffer(encoding); out.write(c.getChars(), 0, c.getUsedSize()); b = b.getNext(); } }
/** * Writes all data written up to the moment to string buffer. * * @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; }