/** * Returns total number of characters stored in this link and all its predecessors. * * @return total number of characters stored in this link and all its predecessors */ public int getTotalSize() { return (prev == null) ? usedSize : prev.getTotalSize() + usedSize; }
/** * 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; }