Packages  This Package  Prev  Next  Index  

§2.10 Class FileOutputStream

public  class  java.io.FileOutputStream
    extends  java.io.OutputStream  (I-§2.15)
{
        // Constructors
    public FileOutputStream(File  file);	§2.10.1
    public FileOutputStream(FileDescriptor  fdObj);	§2.10.2
    public FileOutputStream(String  name);	§2.10.3

        // Methods
    public void close();	§2.10.4
    protected void finalize();	§2.10.5
    public final FileDescriptor getFD();	§2.10.6
    public void write(byte  b[]);	§2.10.7
    public void write(byte  b[], int  off, int  len);	§2.10.8
    public void write(int  b);	§2.10.9
}
A file output stream is an output stream for writing data to a File (I-§2.7) or to a FileDescriptor (I-§2.8).


Constructors

FileOutputStream

public FileOutputStream(File file) throws IOException
Creates an file output stream to write to the specified File object
Parameters:
file - the file to be opened for writing
Throws
IOException (I-§2.29)
If the file could not be opened for writing.
Throws
SecurityException (I-§1.43)
If a security manager exists, its checkWrite method (I-§1.15.24) is called with the path name (I-§2.7.16) of the File argument to see if the application is allowed write access to the file. This may result in a security exception (I-§1.43).

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 (I-§1.43)
If a security manager exists, its checkWrite method (I-§1.15.23) is called with the file descriptor to see if the application is allowed to write to the specified file descriptor. This may result in a security exception (I-§1.43).

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 file name
Throws
IOException (I-§2.29)
If the file could not be opened for writing.
Throws
SecurityException (I-§1.43)
If a security manager exists, its checkWrite method (I-§1.15.24) is called with the name argument to see if the application is allowed write access to the file. This may result in a security exception (I-§1.43).

Methods

close

public void close() throws IOException
Closes this file output stream and releases any system resources associated with this stream.
Throws
IOException (I-§2.29)
If an I/O error occurs.
Overrides:
close in class OutputStream (I-§2.15.2).

finalize

protected void finalize() throws IOException
This finalize method ensures that the close method (I-§2.9.5) of this file output stream is called when there are no more references to this stream.

Throws
IOException (I-§2.29)
If an I/O error occurs.
Overrides:
finalize in class Object (I-§1.12.4).

getFD

public final FileDescriptor getFD() throws IOException
Returns:
the file descriptor object (I-§2.8) associated with this stream.
Throws
IOException (I-§2.29)
If an I/O error occurs.

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 (I-§2.29)
If an I/O error occurs.
Overrides:
write in class OutputStream (I-§2.15.4).

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 (I-§2.29)
If an I/O error occurs.
Overrides:
write in class OutputStream (I-§2.15.5).

write

public void write(int b) throws IOException
Writes the specified byte to this file output stream.
Parameters:
b - the byte to be written
Throws
IOException (I-§2.29)
If an I/O error occurs.
Overrides:
write in class OutputStream (I-§2.15.6).

Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com