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