转自http://blog.csdn.net/qq924862077/
超类OutStream,是以字节为单位的所有输出类的公共父类。
JDk1.8中的OutStream源码:
package java.io;
public abstract class OutputStream implements Closeable, Flushable {
//写特定的字节到输出流
public abstract void write(int b) throws IOException;
//写特定的长度的字节数组到输出流中
public void write(byte b[]) throws IOException {
write(b, 0, b.length);
}
//从b数组中,起始值为off,长度为len的数据到输出流中
public void write(byte b[], int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException();
} else if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
}
for (int i = 0 ; i < len ; i++) {
write(b[off + i]);
}
}
//刷新输出流,强制任意的缓冲输出都被输出
public void flush() throws IOException {
}
//关闭输出流,释放与这个输出流相关的所有系统资源
public void close() throws IOException {
}
}