/** * Returns instance of FastBufferWriter containing all data written to this output stream. * * @return instance of FastBufferWriter containing all data written to this output stream */ public FastBufferWriter convertToWriter() { ByteBuffer c = firstBuffer; CharBuffer first = c.toCharBuffer(); CharBuffer b = first; while (c != null) { c = c.getNext(); if (c == null) { break; } CharBuffer n = c.toCharBuffer(); b.setNext(n); b = n; } return new FastBufferWriter(first); }
/** * Returns instance of FastBufferWriter containing all data written to this output stream. * * @param encoding * @return instance of FastBufferWriter containing all data written to this output stream * @throws UnsupportedEncodingException */ public FastBufferWriter convertToWriter(String encoding) throws UnsupportedEncodingException { ByteBuffer c = firstBuffer; CharBuffer first = c.toCharBuffer(encoding); CharBuffer b = first; while (c != null) { c = c.getNext(); if (c == null) { break; } CharBuffer n = c.toCharBuffer(encoding); b.setNext(n); b = n; } return new FastBufferWriter(first); }
/** * 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(); } }