Java IO Learning (10) Filteroutputstream

Source: Internet
Author: User
Tags flush

Filteroutputstream Introduction

The role of Filteroutputstream is to "encapsulate other output streams and provide them with additional functionality". It mainly includes Bufferedoutputstream, DataOutputStream and PrintStream.

The function of Bufferedoutputstream is to provide buffering function for the output stream.

DataOutputStream is used to decorate other output streams and to work with dataoutputstream and datainputstream input streams, "allowing applications to read and write basic Java data types from the underlying input stream in a machine-independent manner."

(PrintStream) is used to decorate other output streams. It adds functionality to other output streams, enabling them to easily print various data-value representations.

Filteroutputstream Source (based on jdk1.7.40)

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/

Package java.io;
     
public class Filteroutputstream extends OutputStream {
    protected outputstream out;
     
    Public Filteroutputstream (OutputStream out) {
        this.out = out;
    }
     
    public void Write (int b) throws IOException {
        out.write (b);
    }
     
    public void Write (byte b[]) throws IOException {
        write (b, 0, b.length);
     
    public void Write (byte b[], int out, int len) throws IOException {
        if (off | len | (B.length-(len + off) | (off + len)) < 0)
            throw new Indexoutofboundsexception ();
     
        for (int i = 0; i < len; i++) {
            write (B[off + i]);
        }
     
    public void Flush () throws IOException {
        out.flush ();
    }
     
    public void Close () throws IOException {
        try {
          flush ();
        } catch (IOException ignored) {
        }
        Out.close ();
    }

Source: http://www.cnblogs.com/skywang12345/p/io_11.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.