Class FastStringBuffer

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

    public class FastStringBuffer
    extends OutputStream
    This buffer implementation attempts to improve file creation performance by preventing conversion from byte array to string and then back to byte array for writing to a stream. The append method here accepts byte arrays and strings. In the case of a byte array it simply copies the bytes. Very fast. In the case of strings it attempts to convert the string to a byte array once and save the results. In this way we avoid converting each time. If many constant string literals are passed to this class, it will be faster. This string buffer will now accept an output stream in addition which allows this string buffer to act as a buffered output stream.