当前位置 类层次(JDK) 所有类(JDK) 所有域和方法(JDK)

类 java.io.FileOutputStream

java.lang.Object
   |
   +----java.io.OutputStream
           |
           +----java.io.FileOutputStream

public class FileOutputStream
extends OutputStream

文件输出流是向 FileFileDescriptor 输出数据的一个输出流。

来自:
JDK1.0
参见:
File, FileDescriptor, FileInputStream

构造子索引

FileOutputStream(File)
创建一个文件输出流,向指定的 File 对象输出数据。
FileOutputStream(FileDescriptor)
创建一个文件输出流,向指定的文件描述器输出数据。
FileOutputStream(String)
创建一个文件输出流,向指定名称的文件输出数据。
FileOutputStream(String, boolean)
用指定系统的文件名,创建一个输出文件。

方法索引

close()
关闭当前文件输出流,且释放与它相关的任一系统资源。
finalize()
当这个文件输出流不再有引用时,确保调用它的 close 方法。
getFD()
返回与当前流相关的文件描述符。
write(byte[])
将指定字节数组中 b.length 字节写入当前文件输出流。
write(byte[], int, int)
将指定字节数组中以偏移量 off开始的 len个字节写入当前文件输出流。
write(int)
将指定字节写入当前文件输出流。

构造子

FileOutputStream
 public FileOutputStream(String name) throws IOException
创建一个文件输出流,向指定名称的文件输出数据。

参数:
name - 与系统相关的文件名。
抛出: IOException
如果文件不能为写操作打开。
抛出: SecurityException
如果有一个安全管理器,则用给定的参数名调用 checkWrite 方法,查看是否允许应用程序写该文件。
参见:
checkWrite
FileOutputStream
 public FileOutputStream(String name,
                         boolean append) throws IOException
用指定系统的文件名,创建一个输出文件。

参数:
name - 与系统相关的文件名。
抛出: IOException
如果不能找到此文件。
FileOutputStream
 public FileOutputStream(File file) throws IOException
创建一个文件输出流,向指定的 File 对象输出数据。

参数:
file - 为写打开的文件。
抛出: IOException
如果文件不能为写打开。
抛出: SecurityException
如果有一个安全管理器,则用参数 File 给定的路径名调用 checkWrite 方法,查看是否允许此应用程序写该文件。 可能返回安全性异常。
参见:
getPath, SecurityException, checkWrite
FileOutputStream
 public FileOutputStream(FileDescriptor fdObj)
创建一个文件输出流,向指定的文件描述器输出数据。

参数:
fdObj - 为写打开的文件描述符。
抛出: SecurityException
如果有一个安全管理器,则用参数 File 给定的路径名调用 checkWrite 方法,查看是否允许此应用程序写该文件。
参见:
checkWrite

方法

write
 public native void write(int b) throws IOException
将指定字节写入当前文件输出流。

参数:
b - 待写入的字节。
抛出: IOException
如果发生某个 I/O 错误。
覆盖:
OutputStream 中的 write
write
 public void write(byte b[]) throws IOException
将指定字节数组中 b.length 字节写入当前文件输出流。

参数:
b - 数据。
抛出: IOException
如果发生某个 I/O 错误。
覆盖:
OutputStream 中的 write
write
 public void write(byte b[],
                   int off,
                 int len) throws IOException
将指定字节数组中以偏移量 off 开始的 len 个字节写入当前文件输出流。

参数:
b - 数据。
off - 数据的起始偏移。
len - 写入的字节数。
抛出: IOException
如果发生某个 I/O 错误。
覆盖:
OutputStream 中的 write
close
 public native void close() throws IOException
关闭当前文件输出流,且释放与它相关的任一系统资源。

抛出: IOException
如果发生某个 I/O 错误。
覆盖:
OutputStream 中的 close
getFD
 public final FileDescriptor getFD() throws IOException
返回与当前流相关的文件描述符。

返回值:
与当前流相关的文件描述符。
抛出: IOException
如果发生某个 I/O 错误。
参见:
FileDescriptor
finalize
 protected void finalize() throws IOException
当这个文件输出流不再有引用时,确保调用它的 close 方法。

抛出: IOException
如果发生某个 I/O 错误。
覆盖:
Object 中的 finalize
参见:
close

当前位置 类层次(JDK) 所有类(JDK) 所有域和方法(JDK)