| java.lang.Object | |||
| ↳ | java.io.OutputStream | ||
| ↳ | java.io.FilterOutputStream | ||
| ↳ | java.io.BufferedOutputStream | ||
Wraps an existing OutputStream and buffers the output. Expensive interaction with the underlying input stream is minimized, since most (smaller) requests can be satisfied by accessing the buffer alone. The drawback is that some extra space is required to hold the buffer and that copying takes place when flushing that buffer, but this is usually outweighed by the performance benefits. 
 BufferedOutputStream buf = new BufferedOutputStream(new FileOutputStream("file.java"));
 
       
      | Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  | buf | The buffer containing the bytes to be written to the target stream. | |||||||||
|  | count | The total number of bytes inside the byte array buf. | |||||||||
| [Expand] 
           Inherited Fields
           | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  From class java.io.FilterOutputStream | |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  | 
           Constructs a new 
            BufferedOutputStream, providingoutwith a buffer of 8192 bytes. | ||||||||||
|  | 
           Constructs a new 
            BufferedOutputStream, providingoutwithsizebytes of buffer. | ||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  | 
           Closes this stream.
           | ||||||||||
|  | 
           Flushes this stream to ensure all pending data is written out to the target stream.
           | ||||||||||
|  | 
           Writes 
            countbytes from the byte arraybufferstarting atoffsetto this stream. | ||||||||||
|  | 
           Writes one byte to this stream.
           | ||||||||||
| [Expand] 
           Inherited Methods
           | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  From class java.io.FilterOutputStream | |||||||||||
|  From class java.io.OutputStream | |||||||||||
|  From class java.lang.Object | |||||||||||
|  From interface java.io.Closeable | |||||||||||
|  From interface java.io.Flushable | |||||||||||
The buffer containing the bytes to be written to the target stream.
Constructs a new BufferedOutputStream, providing out with a buffer of 8192 bytes.
| out | the OutputStreamthe buffer writes to. | 
|---|
Constructs a new BufferedOutputStream, providing out with size bytes of buffer.
| out | the OutputStreamthe buffer writes to. | 
|---|---|
| size | the size of buffer in bytes. | 
| IllegalArgumentException | if size <= 0. | 
|---|
Closes this stream. This implementation closes the target stream.
| IOException | 
|---|
Flushes this stream to ensure all pending data is written out to the target stream. In addition, the target stream is flushed.
| IOException | if an error occurs attempting to flush this stream. | 
|---|
Writes count bytes from the byte array buffer starting at offset to this stream. If there is room in the buffer to hold the bytes, they are copied in. If not, the buffered bytes plus the bytes in buffer are written to the target stream, the target is flushed, and the buffer is cleared.
| buffer | the buffer to be written. | 
|---|---|
| offset | the start position in bufferfrom where to get bytes. | 
| length | the number of bytes from bufferto write to this stream. | 
| IndexOutOfBoundsException | if offset < 0orlength < 0, or ifoffset + lengthis greater than the size ofbuffer. | 
|---|---|
| IOException | if an error occurs attempting to write to this stream. | 
| NullPointerException | if bufferisnull. | 
| ArrayIndexOutOfBoundsException | If offset or count is outside of bounds. | 
Writes one byte to this stream. Only the low order byte of the integer oneByte is written. If there is room in the buffer, the byte is copied into the buffer and the count incremented. Otherwise, the buffer plus oneByte are written to the target stream, the target is flushed, and the buffer is reset.
| oneByte | the byte to be written. | 
|---|
| IOException | if an error occurs attempting to write to this stream. | 
|---|