Package org.jline.utils
Class FastBufferedOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- org.jline.utils.FastBufferedOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class FastBufferedOutputStream extends java.io.FilterOutputStream
A simple, non-synchronized buffered output stream for improved performance.The FastBufferedOutputStream class provides a buffered output stream implementation that improves performance by reducing the number of calls to the underlying output stream. Unlike the standard BufferedOutputStream, this implementation does not include synchronization, making it faster but not thread-safe.
This class is particularly useful in single-threaded contexts where the overhead of synchronization is unnecessary. It uses a fixed-size buffer (8192 bytes) to collect written data before flushing it to the underlying output stream.
Key features include:
- No synchronization overhead for improved performance
- Fixed-size buffer to reduce system calls
- Compatible with the standard OutputStream API
Note that this class is not thread-safe and should not be used in multi-threaded contexts without external synchronization.
-
-
Constructor Summary
Constructors Constructor Description FastBufferedOutputStream(java.io.OutputStream out)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
void
write(byte[] b, int off, int len)
void
write(int b)
-
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
-