Implements a {@link Reader} over a {@link StringBuilder} instance. Althoughone can use {@link java.io.StringReader} by passing it{@link StringBuilder#toString()}, it is better to use this class, as it doesn't mark the passed-in {@link StringBuilder} as shared (which will causeinner char[] allocations at the next append() attempt). Notes:
This implementation assumes the underlying {@link StringBuilder} 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:
StringBuilder sb = new StringBuilder("some text"); Reader reader = new StringBuilderReader(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.