All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.io.FileOutputStream

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

public class FileOutputStream
extends OutputStream
A file output stream is an output stream for writing data to a File or to a FileDescriptor.

Since:
JDK1.0
See Also:
File, FileDescriptor, FileInputStream

Constructor Index

 o FileOutputStream(File)
Creates a file output stream to write to the specified File object.
 o FileOutputStream(FileDescriptor)
Creates an output file stream to write to the specified file descriptor.
 o FileOutputStream(String)
Creates an output file stream to write to the file with the specified name.
 o FileOutputStream(String, boolean)
Creates an output file with the specified system dependent file name.

Method Index

 o close()
Closes this file output stream and releases any system resources associated with this stream.
 o finalize()
Ensures that the close method of this file output stream is called when there are no more references to this stream.
 o getFD()
Returns the file descriptor associated with this stream.
 o write(byte[])
Writes b.length bytes from the specified byte array to this file output stream.
 o write(byte[], int, int)
Writes len bytes from the specified byte array starting at offset off to this file output stream.
 o write(int)
Writes the specified byte to this file output stream.

Constructors

 o FileOutputStream
 public FileOutputStream(String name) throws IOException
Creates an output file stream to write to the file with the specified name.

Parameters:
name - the system-dependent filename.
Throws: IOException
if the file could not be opened for writing.
Throws: SecurityException
if a security manager exists, its checkWrite method is called with the name argument to see if the application is allowed write access to the file.
See Also:
checkWrite
 o FileOutputStream
 public FileOutputStream(String name,
                         boolean append) throws IOException
Creates an output file with the specified system dependent file name.

Parameters:
name - the system dependent file name
Throws: IOException
If the file is not found.
 o FileOutputStream
 public FileOutputStream(File file) throws IOException
Creates a file output stream to write to the specified File object.

Parameters:
file - the file to be opened for writing.
Throws: IOException
if the file could not be opened for writing.
Throws: SecurityException
if a security manager exists, its checkWrite method is called with the pathname of the File argument to see if the application is allowed write access to the file. This may result in a security exception.
See Also:
getPath, SecurityException, checkWrite
 o FileOutputStream
 public FileOutputStream(FileDescriptor fdObj)
Creates an output file stream to write to the specified file descriptor.

Parameters:
fdObj - the file descriptor to be opened for writing.
Throws: SecurityException
if a security manager exists, its checkWrite method is called with the file descriptor to see if the application is allowed to write to the specified file descriptor.
See Also:
checkWrite

Methods

 o write
 public native void write(int b) throws IOException
Writes the specified byte to this file output stream.

Parameters:
b - the byte to be written.
Throws: IOException
if an I/O error occurs.
Overrides:
write in class OutputStream
 o write
 public void write(byte b[]) throws IOException
Writes b.length bytes from the specified byte array to this file output stream.

Parameters:
b - the data.
Throws: IOException
if an I/O error occurs.
Overrides:
write in class OutputStream
 o write
 public void write(byte b[],
                   int off,
                   int len) throws IOException
Writes len bytes from the specified byte array starting at offset off to this file output stream.

Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws: IOException
if an I/O error occurs.
Overrides:
write in class OutputStream
 o close
 public native void close() throws IOException
Closes this file output stream and releases any system resources associated with this stream.

Throws: IOException
if an I/O error occurs.
Overrides:
close in class OutputStream
 o getFD
 public final FileDescriptor getFD() throws IOException
Returns the file descriptor associated with this stream.

Returns:
the file descriptor object associated with this stream.
Throws: IOException
if an I/O error occurs.
See Also:
FileDescriptor
 o finalize
 protected void finalize() throws IOException
Ensures that the close method of this file output stream is called when there are no more references to this stream.

Throws: IOException
if an I/O error occurs.
Overrides:
finalize in class Object
See Also:
close

All Packages  Class Hierarchy  This Package  Previous  Next  Index

Submit a bug or feature