![]() |
VOOZH | about |
In Java, the BufferedOutputStream class is used to write data to an output stream more efficiently. It adds a buffer to another output stream, reducing the number of I/O operations by temporarily storing data in memory before writing it to the destination (like a file).
It belongs to the java.io package and extends the FilterOutputStream class.
public class BufferedOutputStream extends FilterOutputStream
| Method | Description |
|---|---|
void write(int b) | Writes a single byte to the output stream. |
void write(byte[] b, int off, int len) | Writes a portion of the byte array to the output stream. |
void flush() | Flushes the buffer and forces any buffered output bytes to be written. |
void close() | Closes the stream, flushing it first. |
Output (content of output.txt):
BufferedOutputStream in Java Example
Output (content of flush.txt):
Hello
Output (content of large.txt, first few lines):
Line 0
Line 1
Line 2
...