Implements a {@link Reader} over a {@link StringBuffer} instance. Althoughone can use {@link java.io.StringReader} by passing it{@link StringBuffer#toString()}, it is better to use this class, as it doesn't mark the passed-in {@link StringBuffer} as shared (which will causeinner char[] allocations at the next append() attempt). Notes:
This implementation assumes the underlying {@link StringBuffer} is notchanged during the use of this {@link Reader} implementation.
This implementation is thread-safe.
The implementation looks very much like {@link java.io.StringReader} (forthe right reasons).
If one wants to reuse that instance, then the following needs to be done:
StringBuffer sb = new StringBuffer("some text"); Reader reader = new StringBufferReader(sb); ... read from reader - don't close it ! ... sb.setLength(0); sb.append("some new text"); reader.reset(); ... read the new string from the reader ...
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.