IT. Expert System.

Android Reference

BufferedOutputStream


java.io

Class BufferedOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable


    public class BufferedOutputStream
    extends FilterOutputStream
    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.

    A typical application pattern for the class looks like this:

     BufferedOutputStream buf = new BufferedOutputStream(new FileOutputStream("file.java"));
     
    See Also:
    BufferedInputStream
    • Field Summary

      Fields
      Modifier and Type Field and Description
      protected byte[] buf
      The buffer containing the bytes to be written to the target stream.
      protected int count
      The total number of bytes inside the byte array buf.
    • Field Detail

      • buf

        protected byte[] buf
        The buffer containing the bytes to be written to the target stream.
      • count

        protected int count
        The total number of bytes inside the byte array buf.
    • Constructor Detail

      • BufferedOutputStream

        public BufferedOutputStream(OutputStream out)
        Constructs a new BufferedOutputStream, providing out with a buffer of 8192 bytes.
        Parameters:
        out - the OutputStream the buffer writes to.
      • BufferedOutputStream

        public BufferedOutputStream(OutputStream out,
                            int size)
        Constructs a new BufferedOutputStream, providing out with size bytes of buffer.
        Parameters:
        out - the OutputStream the buffer writes to.
        size - the size of buffer in bytes.
        Throws:
        IllegalArgumentException - if size <= 0.
    • Method Detail

      • flush

        public void flush()
                   throws IOException
        Flushes this stream to ensure all pending data is written out to the target stream. In addition, the target stream is flushed.
        Specified by:
        flush in interface Flushable
        Overrides:
        flush in class FilterOutputStream
        Throws:
        IOException - if an error occurs attempting to flush this stream.
      • write

        public void write(byte[] buffer,
                 int offset,
                 int length)
                   throws IOException
        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.
        Overrides:
        write in class FilterOutputStream
        Parameters:
        buffer - the buffer to be written.
        offset - the start position in buffer from where to get bytes.
        length - the number of bytes from buffer to write to this stream.
        Throws:
        IndexOutOfBoundsException - if offset < 0 or length < 0, or if offset + length is greater than the size of buffer.
        IOException - if an error occurs attempting to write to this stream.
        NullPointerException - if buffer is null.
        ArrayIndexOutOfBoundsException - If offset or count is outside of bounds.
      • write

        public void write(int oneByte)
                   throws IOException
        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.
        Overrides:
        write in class FilterOutputStream
        Parameters:
        oneByte - the byte to be written.
        Throws:
        IOException - if an error occurs attempting to write to this stream.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 693 / 158678355. Delta: 0.03179 с