-
该抽象类是所有类的字节输出流的父类。输出流接受输出字节,并将它们发送到一些接收器。
这需要定义一个类
OutputStream
应用必须至少提供一个方法将输出一个字节 -
直接子类有FileOutputStream,OutputStream等
方法:
-
public class FileOutputStream extends OutputStream
-
文件输出流是一个
File
或一个FileDescriptor
数据写入输出流
-
public FileOutputStream(String name) throws FileNotFoundException
创建一个文件输出流,用指定的名称写入文件
-
public FileOutputStream(String name, boolean append) throws FileNotFoundException
创建一个文件输出流,用指定的名称写入文件。如果第二true
,然后字节将被写入到文件的末尾而不是开头 -
public FileOutputStream(File file) throws FileNotFoundException
创建一个文件输出流写入指定的File
对象表示的文件
-
public FileOutputStream(File file, boolean append) throws FileNotFoundException
创建一个文件输出流写入指定的File
对象表示的文件。如果第二true
,然后字节将被写入到文件的末尾而不是开头。
-
public void write(int b) throws IOException
将指定的字节写入该文件输出流中。实现的方法OutputStream
write
。
-
public void write(byte[] b) throws IOException
写b.length
字节从指定的字节数组来此文件输出流。
-
public void write(byte[] b, int off, int len) throws IOException
写len
字节指定字节数组中的起始偏移off
此文件输出流。
-
public void close() throws IOException
关闭此文件输出流并释放与此流关联的任何系统资源。此文件输出流可能不再用于写入字节
-
protected void finalize() throws IOException
清理文件的连接,并确保此文件输出流的close
方法被调用时,没有引用此流。